How to use the argparse.Action.storeTrue function in argparse

To help you get started, we’ve selected a few argparse 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 syroegkin / swagger-markdown / app / index.js View on Github external
version: packageInfo.version
});

parser.addArgument(['-i', '--input'], {
  required: true,
  help: 'Path to the swagger yaml file',
  metavar: '',
  dest: 'input'
});
parser.addArgument(['-o', '--output'], {
  help: 'Path to the resulting md file',
  metavar: '',
  dest: 'output'
});
parser.addArgument(['--skip-info'], {
  action: Action.storeTrue,
  nargs: 0,
  help: 'Skip the title, description, version etc, whatever is in the info block.',
  metavar: '',
  dest: 'skipInfo'
});
const args = parser.parseArgs();

if (args.input) {
  const document = [];

  try {
    const inputDoc = yaml.safeLoad(fs.readFileSync(args.input, 'utf8'));
    const outputFile = args.output || args.input.replace(/(yaml|yml|json)$/i, 'md');

    // Collect parameters
    const parameters = ('parameters' in inputDoc) ? inputDoc.parameters : {};