Giter Club home page Giter Club logo

cargv's Introduction

๐Ÿณ cargv ๐Ÿš›

The easy way to make command line arguments.

Usage ๐Ÿงช

Importing ๐Ÿ“ฉ

const cargv = require('cargv');

Basic CLI โšพ

const options = cargv.read()
	.add({
		name: 'cool',
		type: 'bool', // or boolean (any number above 0 is true, along with 'on' and 'true')
		aliases: ['cargv_is_cool'],
		default: [false],
		description: 'Is CArgV cool?'
	}).done();
console.log(options);

// Result:
{
	cool: {
		name: 'cool',
		value: [ false ],
		arguments: 0
	}
}

Multiple Arguments 2๏ธโƒฃ

You may have noticed that value is an array. That's because you can have multiple arguments. To add multiple arguments, simply add an arguments property to the option. The arguments property takes an integer which starts from 0. If you'd like different arguments to have different types, just make the type property an array.

Example:

const options = cargv.read()
	.add({
		name: 'cool',
		type: ['bool', 'num'], // or boolean (any number above 0 is true, along with 'on' and 'true')
		aliases: ['cargv_is_cool'],
		default: [false, 5],
		description: 'Is CArgV cool?',
		arguments: 2
	}).done();

Other Types โœ

'boolean' or 'bool'

Can be 'true', 'on', any number above 0 for true. anything else is considered false.

'none'

Takes no arguments. If the tag is present, the value will be true. Recommended use with default set to [false]

'list' or 'array' or 'arr'

Takes a comma seperated (which can be changed by defining a seperator property on the option) list.

'string' or 'str'

Takes anything as a string.

'number' or 'num'

Takes anything as a float.

'any'

A mix of 'string' and 'number'

cargv's People

Contributors

battledash-2 avatar

Watchers

 avatar

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.