How to use command-line-usage - 8 common examples

To help you get started, we’ve selected a few command-line-usage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github open-wc / open-wc / packages / es-dev-server / src / command-line-args.js View on Github external
// convert kebab-case to camelCase
  /** @type {object} */
  const args = Object.keys(dashesArgs).reduce((acc, key) => {
    acc[camelcase(key)] = dashesArgs[key];
    return acc;
  }, {});

  if (args.debug) {
    setDebug(true);
  }

  if ('help' in args) {
    /* eslint-disable-next-line no-console */
    console.log(
      commandLineUsage([
        {
          header: 'es-dev-server',
          content: `
          A dev server for modern web development workflows.

          Usage: \`es-dev-server [options...]\`
        `.trim(),
        },
        {
          header: 'Global Options',
          optionList: commandLineOptions,
        },
      ]),
    );
    process.exit();
  }
github debitoor / nocms / packages / nocms / src / bin / nocms.js View on Github external
options = commandLineArgs(optionDefinitions, { argv: result.argv });

			const valid = optionDefinitions
				.filter(optionDefinition => optionDefinition.required)
				.every(optionDefinition => Object.keys(options).indexOf(optionDefinition.name) >= -1);

			if (!valid) {
				options.help = true;
			}
		} catch (err) {
			command = command || '';
			options = { help: true };
		}

		if (options.help) {
			const usage = commandLineUsage(commandUsageDefinitions[command] || defaultUsageDefinition);
			console.log(usage);
			return;
		}

		const inDir = options['in-dir'];
		const outDir = options['out-dir'];
		const port = options['port'];
		const concurrency = options['concurrency'];

		// Load config rc file
		const config = await loadConfig(inDir);

		// Create an array to hold all the resource providers.
		const resourceProviders = [];

		// Create a function that plugins can use to register resource providers.
github google / intermock / src / cli / index.ts View on Github external
function showWelcomeMessage() {
  const usage = commandLineUsage(instructions);
  console.log(usage);
}
github Tencent / feflow / packages / feflow-cli / src / core / index.ts View on Github external
if(optionDescrition.optionList.length == 0) {
            return this.call("help", ctx)
        }

        const sections = [];
        sections.push({
            header: `fef ${cmd}`,
            content: cmdDescription
        })
        sections.push({
            header: 'Usage',
            content: `$ fef ${cmd} [options]`
        })
        sections.push(optionDescrition);
        const usage = commandLineUsage(sections);

        console.log(usage);
    }
github SpoonX / stix / src / Library / Command / HelpCommand.ts View on Github external
const collectedExamples: string[] = [];

    Object.values(programs).forEach(({ program, commands, examples }: ProcessedProgramType) => {
      sections.push({ content: chalk.yellow(program), raw: true });
      sections.push({ content: Object.keys(commands).map((command: string) => this.renderCommand(commands[ command ])) });

      if (Array.isArray(examples)) {
        collectedExamples.push(...examples);
      }
    });

    if (collectedExamples) {
      sections.push(this.renderExamples(collectedExamples));
    }

    output.addData(commandLineUsage(sections));
  }
github sharvit / mongoose-data-seed / src / lib / commands / generate / usage-guide.js View on Github external
import generateUsageGuide from 'command-line-usage';
import optionDefinitions from './option-definitions';

/**
 * @private
 */
const usageGuide = generateUsageGuide([
  {
    header: 'Generate Seeder',
    content: 'Generate new seeder file into the seeder folder.',
  },
  {
    header: 'Synopsis',
    content: [
      '$ md-seed generate {underline seeder-name}',
      '$ md-seed g {underline seeder-name}',
      '$ md-seed g {bold --help}',
    ],
  },
  {
    header: 'Options',
    optionList: optionDefinitions,
  },
github bradleyboy / tuql / src / bin / index.js View on Github external
defaultValue: 4000,
    description: 'Port to run on (Default: 4000)',
  },
  {
    name: 'schema',
    alias: 's',
    type: Boolean,
    description: 'Write string representation of schema to stdout',
  },
  { name: 'help', alias: 'h', type: Boolean, description: 'This help output' },
];

const options = commandLineArgs(optionDefinitions);

if (options.help) {
  const usage = commandLineUsage([
    {
      header: 'tuql',
      content:
        '{underline tuql} turns just about any sqlite database into a graphql endpoint, including inferring associations',
    },
    {
      header: 'Basic usage',
      content: 'tuql --db path/to/db.sqlite',
    },
    {
      header: 'Options',
      optionList: optionDefinitions,
    },
    {
      content: 'Project home: {underline https://github.com/bradleyboy/tuql}',
    },
github sharvit / mongoose-data-seed / src / lib / commands / init / usage-guide.js View on Github external
import generateUsageGuide from 'command-line-usage';
import optionDefinitions from './option-definitions';

/**
 * @private
 */
const usageGuide = generateUsageGuide([
  {
    header: 'Initialize mongoose-data-seed',
    content: `Install mongoose-data-seed into your project.
      Generate md-seed-config.js, md-seed-generator.js and create seeders folder`,
  },
  {
    header: 'Synopsis',
    content: [
      '$ md-seed init [{bold --seedersFolder}={underline folder-name}] [{bold --seederTemplate}={underline file-path}]',
      '$ md-seed init {bold --help}',
    ],
  },
  {
    header: 'Options',
    optionList: optionDefinitions,
  },

command-line-usage

Generates command-line usage information

MIT
Latest version published 1 year ago

Package Health Score

70 / 100
Full package analysis

Popular command-line-usage functions