Sha256: 29a1f45d44cbedad7ec4b25c4cd2e0e55011fabb066d1b8e1babe27de4e3b050

Contents?: true

Size: 1 KB

Versions: 139

Compression:

Stored size: 1 KB

Contents

#!/usr/bin/env node
'use strict';

var ArgumentParser = require('../lib/argparse').ArgumentParser;
var parser = new ArgumentParser({
  version: '0.0.1',
  addHelp: true,
  description: 'Argparse examples: constant'
});

parser.addArgument(
  [ '-a'],
  {
    action: 'storeConst',
    dest:   'answer',
    help:   'store constant',
    constant: 42
  }
);
parser.addArgument(
  [ '--str' ],
  {
    action: 'appendConst',
    dest:   'types',
    help:   'append constant "str" to types',
    constant: 'str'
  }
);
parser.addArgument(
  [ '--int' ],
  {
    action: 'appendConst',
    dest:   'types',
    help:   'append constant "int" to types',
    constant: 'int'
  }
);

parser.addArgument(
  [ '--true' ],
  {
    action: 'storeTrue',
    help: 'store true constant'
  }
);
parser.addArgument(
  [ '--false' ],
  {
    action: 'storeFalse',
    help: 'store false constant'
  }
);

parser.printHelp();
console.log('-----------');

var args;
args = parser.parseArgs('-a --str --int --true'.split(' '));
console.dir(args);

Version data entries

139 entries across 125 versions & 8 rubygems

Version Path
ela-4.1.6 node_modules/argparse/examples/constants.js
ela-4.1.5 node_modules/argparse/examples/constants.js
ela-4.1.4 node_modules/argparse/examples/constants.js
ela-4.1.3 node_modules/argparse/examples/constants.js
ela-4.1.2 node_modules/argparse/examples/constants.js
ela-4.1.1 node_modules/argparse/examples/constants.js
ela-4.1.0 node_modules/argparse/examples/constants.js
ela-4.0.0 node_modules/argparse/examples/constants.js
opal-0.10.6 stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/constants.js
opal-0.10.6.beta stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/constants.js
ela-3.4.3 node_modules/argparse/examples/constants.js
ela-3.4.2 node_modules/argparse/examples/constants.js
ela-3.4.0 node_modules/argparse/examples/constants.js
ela-3.3.1 node_modules/argparse/examples/constants.js
ela-3.3.0 node_modules/argparse/examples/constants.js
ela-3.2.0 node_modules/argparse/examples/constants.js
ela-3.1.1 node_modules/argparse/examples/constants.js
ela-3.1.0 node_modules/argparse/examples/constants.js
ela-3.0.0 node_modules/argparse/examples/constants.js
ela-2.0.0 node_modules/argparse/examples/constants.js