How to use the terminalWidth function from yargs

Find comprehensive JavaScript yargs.terminalWidth code examples handpicked from public code repositorys.

81
82
83
84
85
86
87
88
89
90
}

function argsParser () {
  return yargs
    .detectLocale(false)
    .wrap(Math.min(120, yargs.terminalWidth()))
    .command('$0 [files...]', '', function (yargs) {
      return yargs
        .option('doctype', {
          alias: 'd',
fork icon128
star icon195
watch icon13

+ 7 other calls in file

31
32
33
34
35
36
37
38
39
40
            boolean: true,
            default: false,
            description: 'output debug infos'
        },
    })
    .wrap(Math.min(120, yargsPkg.terminalWidth()))
    .help();

const argv = yargs.parse();
if (argv.debug) {
fork icon121
star icon0
watch icon20

53
54
55
56
57
58
59
60
61
62
  shouldNotifyInNpmScript: true,
  message: pkg.name === '@hubspot/cms-cli' ? CLI_UPGRADE_MESSAGE : null,
});

const getTerminalWidth = () => {
  const width = yargs.terminalWidth();

  if (width >= 100) return width * 0.9;

  return width;
fork icon52
star icon124
watch icon95

45
46
47
48
49
50
51
52
53
54
      this.atomDirectory = config.getAtomDirectory()
      this.atomPackagesDirectory = path.join(this.atomDirectory, 'packages')
    }

    parseOptions (argv) {
      const options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()))
      options.usage(`\

Usage: apm upgrade
       apm upgrade --list
fork icon0
star icon1
watch icon2

111
112
113
114
115
116
117
118
119
120
    }
  })
  .alias('v', 'version')
  .env('hoodie')
  .epilogue('Options can also be specified as environment variables (prefixed with "hoodie_") or inside a ".hoodierc" file (json or ini).')
  .wrap(Math.min(150, yargs.terminalWidth()))
  .argv

if (options.bindAddress) {
  log.warn('The use of --bindAddress is deprecated. Use the --address option instead.')
fork icon460
star icon0
watch icon3

32
33
34
35
36
37
38
39
40
41
  .default('m', false)

  .help('h')
  .alias('h', 'help')
  .strict()
  .wrap(Math.min(110, yargs.terminalWidth()))
  .argv

const buildDir = path.resolve(__dirname, '../../build/')
const builtFileNames = fs.readdirSync(buildDir).filter(x => !config.m ? !x.endsWith('.map') : x)
fork icon26
star icon39
watch icon10

91
92
93
94
95
96
97
98
99
100

      return true;
    })
    .demandCommand(1, 'Command must be specified.')
    .help()
    .wrap(Math.min(120, yargs.terminalWidth())).argv;
};

export type Args = Omit<ReturnType<typeof parse>, 'address'> & {
  address: string;
fork icon4
star icon1
watch icon3

16
17
18
19
20
21
22
23
24
25
  .commandDir('../cmds').demandCommand(1, 'Please specify command to execute')
  .epilog('Copyright 2017 Volodymyr Shymanskyy')
  .alias('h', 'help')
  .global('version', false)
  .completion('completion', false)
  .strict().wrap(Math.min(120, yargs.terminalWidth()))
  .recommendCommands();

//yargs.group(['help', 'verbose', 'silent'], 'Global Arguments:');
//yargs.count('verbose').alias('v', 'verbose');
fork icon4
star icon0
watch icon0

Other functions in yargs

Sorted by popularity

function icon

yargs.argv is the most popular function in yargs (1012 examples)