a no-nonsense framework for command-line switch parsing and command dispatching.

switchit enables you to write modern command-line applications using a straightforward OOP-based, promise-enabled API with amazing additional features including:

switchit is built on node.js and installed through npm.

see it in action

make sure to check all our examples!

how to use

  1. use npm to include it in your project:
    $ npm install switchit --save
  2. import one or more of our classes to use:
     const {
       Command,
       Container,
       Help
     } = require('switchit');
  3. write a command:
     class Hi extends Command {
         execute (params) {
             console.log(`Hi, ${params.name}!`);
         }
     }
     Hi.define({
         params: '{name}'
     });
     new Hi().run();
  4. run your command:
    $ node mycommand.js Tim
     Hi, Tim!
     $ node mycommand.js --name Tim
     Hi, Tim!
  5. you're all set! from here you can: take advantage of the promise-enabled dispatching, create some child-classes, make it interactive, add some optional parameters... you name it!
    don't forget to check all features and examples for more information!

learn more

take a good look at the README file for a quick glance on what switchit can do.

read our docs for even more information

get involved

have you found (and maybe even fixed) a bug?
is there a feature you think is missing?
do you want to share your awesome project built with switchit? let us know!