Necessary Pigeonholing Mechanism
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    @ls-age/exposepublic

    @ls-age/expose

    Work in progress

    The easy way to expose a module for CLI usage

    Greenkeeper badge

    Installation

    npm install --save @ls-age/expose

    Usage

    import Expose, { Command, NumberOption } from '@ls-age/expose';
    import { version, description } from '../package.json';
     
    const cli = new Expose({ description });
    cli.addHelp();
    cli.addVersion(version);
     
    const testCommand = new Command({
      name: 'test',
      description: 'Just for testing',
      alias: 'try',
      run({ options }) {
        console.log('Running test command with options', options);
      },
    });
    testCommand.addOption(new NumberOption({
      name: 'log-level',
      description: 'Set log level',
      alias: 'l',
      async set(level) {
        console.log('Setting log level to', level);
     
        // Setting the log level takes some time, so we use an async function
        await new Promise(resolve => setTimeout(resolve, 1000));
     
        console.log('Log level was set');
      },
    }));
    cli.addCommand(testCommand);
     
    cli.run();

    Keywords

    none

    install

    npm i @ls-age/expose

    Downloadslast 7 days

    59

    version

    0.3.0

    license

    MIT

    repository

    github.com

    last publish

    collaborators

    • avatar
    • avatar