bin/swagger-cli.js
function parseArgs () {
  // Configure the argument parser
  yargs
    .option("schema", {
      type: "boolean",
      default: true,
    })
    .option("spec", {
      type: "boolean",
      default: true,
    })
    .option("o", {
      alias: "outfile",
      type: "string",
      normalize: true,
    })
    .option("r", {
      alias: "dereference",
      type: "boolean",
    })
    .option("t", {
      alias: "type",
      type: "string",
      normalize: true,
      default: "json",
    })
    .option("f", {
      alias: "format",
      type: "number",
      default: 2,
    })
    .option("w", {
      alias: "wrap",
      type: "number",
      default: Infinity,
    })
    .option("d", {
      alias: "debug",
      type: "boolean",
    })
    .option("h", {
      alias: "help",
      type: "boolean",
    });

  // Show the version number on "--version" or "-v"
  yargs
    .version()
    .alias("v", "version");

  // Disable the default "--help" behavior
  yargs.help(false);

  // Parse the command-line arguments
  let args = yargs.argv;

  // Normalize the parsed arguments
  let parsed = {
    command: args._[0],
    file: args._[1],
    options: {
      schema: args.schema,
      spec: args.spec,
      outfile: args.outfile,
      dereference: args.dereference,
      format: args.format || 2,
      type: args.type || "json",
      wrap: args.wrap || Infinity,
      debug: args.debug,
      help: args.help,
    }
  };

  if (parsed.options.debug) {
    console.log(JSON.stringify(parsed, null, 2));
  }

  return parsed;
}
function parseArgs () {
  // Configure the argument parser
  yargs
    .option("schema", {
      type: "boolean",
      default: true,
    })
    .option("spec", {
      type: "boolean",
      default: true,
    })
    .option("o", {
      alias: "outfile",
      type: "string",
      normalize: true,
    })
    .option("r", {
      alias: "dereference",
      type: "boolean",
    })
    .option("t", {
      alias: "type",
      type: "string",
      normalize: true,
      default: "json",
    })
    .option("f", {
      alias: "format",
      type: "number",
      default: 2,
    })
    .option("w", {
      alias: "wrap",
      type: "number",
      default: Infinity,
    })
    .option("d", {
      alias: "debug",
      type: "boolean",
    })
    .option("h", {
      alias: "help",
      type: "boolean",
    });

  // Show the version number on "--version" or "-v"
  yargs
    .version()
    .alias("v", "version");

  // Disable the default "--help" behavior
  yargs.help(false);

  // Parse the command-line arguments
  let args = yargs.argv;

  // Normalize the parsed arguments
  let parsed = {
    command: args._[0],
    file: args._[1],
    options: {
      schema: args.schema,
      spec: args.spec,
      outfile: args.outfile,
      dereference: args.dereference,
      format: args.format || 2,
      type: args.type || "json",
      wrap: args.wrap || Infinity,
      debug: args.debug,
      help: args.help,
    }
  };

  if (parsed.options.debug) {
    console.log(JSON.stringify(parsed, null, 2));
  }

  return parsed;
}
function parseArgs ( ) { // Configure the argument parser yargs . option ( "schema" , { type : "boolean" , default : true , } ) . option ( "spec" , { type : "boolean" , default : true , } ) . option ( "o" , { alias : "outfile" , type : "string" , normalize : true , } ) . option ( "r" , { alias : "dereference" , type : "boolean" , } ) . option ( "t" , { alias : "type" , type : "string" , normalize : true , default : "json" , } ) . option ( "f" , { alias : "format" , type : "number" , default : 2 , } ) . option ( "w" , { alias : "wrap" , type : "number" , default : Infinity , } ) . option ( "d" , { alias : "debug" , type : "boolean" , } ) . option ( "h" , { alias : "help" , type : "boolean" , } ) ; // Show the version number on "--version" or "-v" yargs . version ( ) . alias ( "v" , "version" ) ; // Disable the default "--help" behavior yargs . help ( false ) ; // Parse the command-line arguments let args = yargs . argv ; // Normalize the parsed arguments let parsed = { command : args . _ [ 0 ] , file : args . _ [ 1 ] , options : { schema : args . schema , spec : args . spec , outfile : args . outfile , dereference : args . dereference , format : args . format || 2 , type : args . type || "json" , wrap : args . wrap || Infinity , debug : args . debug , help : args . help , } } ; if ( parsed . options . debug ) { console . log ( JSON . stringify ( parsed , null , 2 ) ) ; } return parsed ; }
Parses the command-line arguments

@returns {object} - The parsed arguments
Parses the command - line arguments