Newline Proliferating Maniac

    argumentate

    3.0.0 • Public • Published

    Argumentate

    A very simple argv parser

    Installation

    npm install argumentate

    Usage

    // make executable (not required, but needed if you are building a cli with a bin file (remember to put bin in your package.json!))
    #!/usr/bin/env node
    
    // import argumentate
    let argumentate = require('argumentate');
    
    // slice to remove path args
    let { options, variables } = argumentate({
    	args: process.argv.slice(2),
    	mapping: {
    		c: 'config',
    		p: {
    			key: 'port',
    			help: 'Port to use when launching this command'
    		}
    	},
    	config: {
    		name: 'My CLI',
    		command: 'invoke-like-this'
    	}
    );
    
    // be happy

    Mappings

     const { options, variables } = argumentate({
     	args: ['start', '-p=8080', '-c', './myconfig.json'],
     	mapping: {
    	 	c: 'config',
    		p: {
    			key: 'port',
    			help: 'Port to use when launching this command'
    		}
     	}
     );
    
    // returns
    { 
    	options: {
    		port: '8080',
    		config: './myconfig.json'
    	},
    	variables: ['start']
    }

    Install

    npm i argumentate

    DownloadsWeekly Downloads

    2

    Version

    3.0.0

    License

    MIT

    Unpacked Size

    9.76 kB

    Total Files

    6

    Last publish

    Collaborators

    • jsmrcaga