GithubHelp home page GithubHelp logo

cjpatoilo / rasper Goto Github PK

View Code? Open in Web Editor NEW
15.0 2.0 1.0 794 KB

Node.js parse argument options make ease.

Home Page: https://cjpatoilo.com/rasper

License: MIT License

JavaScript 100.00%
argv arguments cli bin utility command parser option cmd

rasper's Introduction

Rasper - Node.js parse argument options make ease.

Node.js parse argument options make ease.

Travis Status AppVeyor Status Codacy Status Dependencies Status Version Status Download Status Gitter Chat

Why it's awesome

Rasper transforms command arguments into an easy-to-use formatted object. Flags will be converted into key-value. If there is define flag without value the result will be assumed to be true. Boolean-looking arguments always will be returned as booleans. Numeric-looking arguments always will be returned as numbers. _ contains all arguments that didn't have an flag associated.

Getting Started

Install with npm

$ npm install rasper

Install with Yarn

$ yarn add rasper

Run with npx (without installing)

$ npx rasper

Usage

// cli.js
const argv = require('rasper')
console.dir(argv)

// console
$ pwa-installer dist/**/*.html -f 3 -n -o 4 foo bar baz --manifest --config=pwa.config.js 2 4 -f=99
{
  _: [ 'dist/**/*.html', 'foo', 'bar', 'baz', 2, 4 ],
  n: true,
  o: 4,
  manifest: true,
  config: 'pwa.config.js',
  f: 99
}

Note: If you don't provide an argument process.argv.slice(1) is defined by default.

Contributing

Want to contribute? Follow these recommendations.

License

Designed with โ™ฅ by CJ Patoilo. Licensed under the MIT License.

rasper's People

Contributors

cjpatoilo avatar dependabot[bot] avatar luciorubeens avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

luciorubeens

rasper's Issues

Arguments containing dashes are not parsed correctly

I've tried using the initify package, however, if I choose a license with a 'dash' the value is not recognized.

Steps to reproduce

initify my-app --license apache-2.0

Expected behavior

{
  _: ['my-app'],
  license: 'apache-2.0'
}

Actual behavior

{
  _: ['my-app'],
  license: 'apache2.0'
}

So the license file is not found.

Default arguments containing the file path execution

Steps to reproduce

$ yarn global add banner-cli
$ banner-cli dist/*.css
#  => { _:
#   [ '/Users/zce/.config/yarn/bin/banner-cli',
#     'dist/zce-design.css' ] }

Expected behavior

process.argv.slice(1)
// => [ <execution file path>, ...other args ]

Actual behavior

process.argv.slice(2)

System configuration

  • Node version: v10.13.0
  • npm version: v6.4.1
  • yarn version: v1.12.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.