yargs#terminalWidth TypeScript Examples

The following examples show how to use yargs#terminalWidth. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: cli_index.ts    From tda-api-client with GNU General Public License v3.0 6 votes vote down vote up
yargs(hideBin(process.argv))
    // .commandDir("cli", { extensions: ["js, ts"]})
    .command(accountsCli)
    .command(authenticationCli)
    .command(instrumentsCli)
    .command(markethoursCli)
    .command(moversCli)
    .command(optionschainCli)
    .command(ordersCli)
    .command(pricehistoryCli)
    .command(quotesCli)
    .command(savedordersCli)
    .command(transactionsCli)
    .command(userinfoCli)
    .command(watchlistsCli)
    .demandCommand()
    .help()
    .wrap(terminalWidth())
    .option("verbose", {description: "Print to console some extra information", type: "boolean"})
    .argv;
Example #2
Source File: index.ts    From hoprnet with GNU General Public License v3.0 5 votes vote down vote up
argv = yargs(process.argv.slice(2))
  .env('HOPR_CTD') // enable options to be set as environment variables with the HOPR_CTD prefix
  .epilogue(
    'All CLI options can be configured through environment variables as well. CLI parameters have precedence over environment variables.'
  )
  .option('environment', {
    string: true,
    describe: 'Environment id which the node shall run on (HOPR_CTD_ENVIRONMENT)',
    choices: supportedEnvironments().map((env) => env.id),
    default: defaultEnvironment()
  })
  .option('privateKey', {
    describe: 'A private key to be used for the node [env: HOPR_CTD_PRIVATE_KEY]',
    string: true,
    demandOption: true
  })
  .option('provider', {
    string: true,
    describe: 'A custom RPC provider to be used for the node to connect to blockchain [env: HOPR_CTD_PROVIDER]'
  })
  .option('dbFile', {
    describe: 'A path to DB file for persistent storage [env: HOPR_CTD_DB_FILE]',
    string: true,
    default: './ct.json'
  })
  .option('data', {
    string: true,
    describe: 'manually specify the data directory to use [env: HOPR_CTD_DATA]',
    default: defaultDataPath
  })
  .option('healthCheck', {
    boolean: true,
    describe: 'Run a health check end point on localhost:8080 [env: HOPR_CTD_HEALTH_CHECK]',
    default: false
  })
  .option('healthCheckHost', {
    describe: 'Host to listen on for health check [env: HOPR_CTD_HEALTH_CHECK_HOST]',
    default: 'localhost'
  })
  .option('healthCheckPort', {
    describe: 'Port to listen on for health check [env: HOPR_CTD_HEALTH_CHECK_PORT]',
    default: 8080
  })
  .option('allowLocalNodeConnections', {
    boolean: true,
    describe: 'Allow connections to other nodes running on localhost [env: HOPR_CTD_ALLOW_LOCAL_NODE_CONNECTIONS]',
    default: false
  })
  .option('testAnnounceLocalAddresses', {
    boolean: true,
    describe: 'For testing local testnets. Announce local addresses [env: HOPR_CTD_TEST_ANNOUNCE_LOCAL_ADDRESSES]',
    default: false
  })
  .option('testPreferLocalAddresses', {
    boolean: true,
    describe: 'For testing local testnets. Prefer local peers to remote [env: HOPR_CTD_TEST_PREFER_LOCAL_ADDRESSES]',
    default: false
  })
  .wrap(Math.min(120, terminalWidth()))
  .parseSync()
Example #3
Source File: yargs.ts    From tesseract-server with MIT License 4 votes vote down vote up
createYargs = (argv: readonly string[], cwd?: string) =>
  Yargs(argv, cwd)
    .parserConfiguration({
      'dot-notation': false,
      'camel-case-expansion': false,
    })
    .wrap(terminalWidth())
    .scriptName('tesseract-server')
    .usage(
      [
        '$0 [options]',
        '',
        'A small lightweight http server exposing tesseract as a service.',
      ].join('\n'),
    )
    .options({
      'pool.default.min': {
        description: 'Minimum number of processes to keep waiting in each pool',
        default: 0,
        type: 'number',
      },
      'pool.default.max': {
        description:
          'Maximum number of processes to spawn for each pool after which requests are queued',
        default: 2,
        type: 'number',
      },
      'pool.default.idleTimeoutMillis': {
        description:
          'Time (in milliseconds) a processes can stay idle in queue before eviction',
        default: 5000,
        type: 'number',
      },
      'pool.default.evictionRunIntervalMillis': {
        description: 'Time interval (in milliseconds) between eviction checks',
        default: 5000,
        type: 'number',
      },
      'http.listen.address': {
        description: 'Set http listen address',
        default: process.env.HOST != null ? process.env.HOST : '0.0.0.0',
        type: 'string',
      },
      'http.listen.port': {
        description: 'Set http listen port',
        default: process.env.PORT != null ? Number(process.env.PORT) : 8884,
        type: 'number',
      },
      'http.upload.tmpDir': {
        description: 'Path to where temp uploads are saved to',
        default: tmpdir(),
        type: 'string',
      },
      'http.endpoint.status.enable': {
        description: 'Enable /status endpoint',
        default: true,
        type: 'boolean',
      },
      'http.endpoint.health.enable': {
        description:
          'Enable /.well-known/health/* endpoints and health checkers',
        default: true,
        type: 'boolean',
      },
      'http.endpoint.webui.enable': {
        description: 'Enable Web UI at /',
        default: true,
        type: 'boolean',
      },
      'http.input.optionsField': {
        description: 'Multipart field name containing OCR Options',
        default: 'options',
        type: 'string',
      },
      'http.input.fileField': {
        description: 'Multipart field name containing OCR file',
        default: 'file',
        type: 'string',
      },
      'http.output.jsonSpaces': {
        description:
          'Enable json pretty printing and set number of spaces to use for indentation',
        default: 0,
        type: 'number',
      },
      'processor.lineEndings': {
        description: 'Set line ending policy',
        type: 'string',
        default: 'auto',
        choices: [
          ProcessorSettingsLineEndings.AUTO,
          ProcessorSettingsLineEndings.LF,
          ProcessorSettingsLineEndings.CRLF,
        ],
      },
    })
    .example([
      ['$0 --http.output.jsonSpaces 2', 'Enable JSON pretty printing'],
      [
        '$0 --http.endpoint.status.enable false --http.endpoint.health.enable false',
        'Disable Status and Health endpoints',
      ],
    ])
    .epilogue(
      [
        'References:',
        '  GitHub: https://github.com/hertzg/tesseract-server',
        '  Discussions: https://github.com/hertzg/tesseract-server/discussions',
        '  Issues: https://github.com/hertzg/tesseract-server/issues',
      ].join('\n'),
    )