How to use the argparse.Const 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 SRA-SiliconValley / jalangi / src / js / commands / direct2.js View on Github external
// Author: Koushik Sen

/*jslint node: true */
/*global process */
/*global J$ */

var argparse = require('argparse');
var parser = new argparse.ArgumentParser({
    addHelp: true,
    description: "Command-line utility to perform Jalangi's analysis2"
});
parser.addArgument(['--analysis'], { help: "absolute path to analysis file to run", action:'append'});
parser.addArgument(['--initParam'], { help: "initialization parameter for analysis, specified as key:value", action:'append'});
parser.addArgument(['script_and_args'], {
    help: "script to record and CLI arguments for that script",
    nargs: argparse.Const.REMAINDER
});
var args = parser.parseArgs();

function runAnalysis(initParam) {
    if (args.script_and_args.length === 0) {
        console.error("must provide script to record");
        process.exit(1);
    }
    // we shift here so we can use the rest of the array later when
    // hacking process.argv; see below
    var script = args.script_and_args.shift();

    var path = require('path');
    var Headers = require('./../Headers2');
    Headers.headerSources.forEach(function(src){
        require('./../../../'+src);
github SRA-SiliconValley / jalangi / src / js / commands / record.js View on Github external
/*jslint node: true */
/*global process */
/*global J$ */

var argparse = require('argparse');
var DEFAULT_TRACE_FILE_NAME = 'jalangi_trace';
var parser = new argparse.ArgumentParser({
    addHelp: true,
    description: "Command-line utility to perform Jalangi's record phase"
});
parser.addArgument(['--smemory'], { help: "Use shadow memory", action: 'storeTrue'});
parser.addArgument(['--tracefile'], { help: "Location to store trace file", defaultValue: DEFAULT_TRACE_FILE_NAME });
parser.addArgument(['--analysis'], { help: "absolute path to analysis file to run during record", action:"append"});
parser.addArgument(['script_and_args'], {
    help: "script to record and CLI arguments for that script",
    nargs: argparse.Const.REMAINDER
});
var args = parser.parseArgs();
if (args.script_and_args.length === 0) {
    console.error("must provide script to record");
    process.exit(1);
}
// we shift here so we can use the rest of the array later when
// hacking process.argv; see below
var script = args.script_and_args.shift();

global.JALANGI_MODE="record";
global.USE_SMEMORY=args.smemory;

var path = require('path');
var Headers = require('./../Headers');
Headers.headerSources.forEach(function(src){
github Samsung / jalangi2 / src / js / commands / branchJalangi.js View on Github external
// Author: Koushik Sen
// Author: Manu Sridharan

/*jslint node: true */
/*global process */
/*global J$ */

var argparse = require('argparse');
var parser = new argparse.ArgumentParser({
    addHelp: true,
    description: "Command-line utility to perform Jalangi2's instrumentation and analysis"
});
parser.addArgument(['--analysis'], {help: "absolute path to analysis file to run", action: 'append'});
parser.addArgument(['script_and_args'], {
    help: "script to record and CLI arguments for that script",
    nargs: argparse.Const.REMAINDER
});
var args = parser.parseArgs();

if (args.script_and_args.length === 0) {
    console.error("must provide script to record");
    process.exit(1);
}
// we shift here so we can use the rest of the array later when
// hacking process.argv; see below
var script = args.script_and_args.shift();

var Module = require('module');
var path = require('path');
var fs = require('fs');
var originalLoader = Module._extensions['.js'];
var FILESUFFIX1 = "_jalangi_";
github SRA-SiliconValley / jalangi / src / js / commands / symbolic.js View on Github external
// Author: Manu Sridharan

/*jslint node: true */
/*global J$ */

var argparse = require('argparse');
var parser = new argparse.ArgumentParser({
    addHelp: true,
    description: "Command-line utility to perform Jalangi's pure symbolic execution"
});
parser.addArgument(['analysis'], {
    help: "absolute path to symbolic execution code"
});
parser.addArgument(['script_and_args'], {
    help: "script to run symbolically and its arguments",
    nargs: argparse.Const.REMAINDER
});
var args = parser.parseArgs();
if (args.script_and_args.length === 0) {
    console.error("must provide script to record");
    process.exit(1);
}
// we shift here so we can use the rest of the array later when
// hacking process.argv; see below
var script = args.script_and_args.shift();


global.JALANGI_MODE="symbolic";
global.USE_SMEMORY=args.smemory;
global.ANALYSIS_SCRIPT=args.analysis;

var path = require('path');
github SRA-SiliconValley / jalangi / src / js / commands / direct.js View on Github external
/*jslint node: true */
/*global process */
/*global J$ */

var argparse = require('argparse');
var parser = new argparse.ArgumentParser({
    addHelp: true,
    description: "Command-line utility to perform Jalangi's direct analysis"
});
parser.addArgument(['--smemory'], { help: "Use shadow memory", action: 'storeTrue'});
parser.addArgument(['--analysis'], { help: "absolute path to analysis file to run", action:'append'});
parser.addArgument(['--initParam'], { help: "initialization parameter for analysis, specified as key:value", action:'append'});
parser.addArgument(['script_and_args'], {
    help: "script to record and CLI arguments for that script",
    nargs: argparse.Const.REMAINDER
});
var args = parser.parseArgs();

function runAnalysis(initParam) {
    if (args.script_and_args.length === 0) {
        console.error("must provide script to execute");
        process.exit(1);
    }
    // we shift here so we can use the rest of the array later when
    // hacking process.argv; see below
    var script = args.script_and_args.shift();

    global.JALANGI_MODE="inbrowser";
    global.USE_SMEMORY=args.smemory;

    var path = require('path');
github Samsung / jalangi2 / src / js / commands / jalangi.js View on Github external
/*global J$ */

var argparse = require('argparse');
var instUtil = require('../instrument/instUtil');
var parser = new argparse.ArgumentParser({
    addHelp: true,
    description: "Command-line utility to perform Jalangi2's instrumentation and analysis"
});
parser.addArgument(['--analysis'], {help: "absolute path to analysis file to run", action: 'append'});
parser.addArgument(['--initParam'], { help: "initialization parameter for analysis, specified as key:value", action:'append'});
parser.addArgument(['--inlineIID'], {help: "Inline IID to (beginLineNo, beginColNo, endLineNo, endColNo) in J$.iids in the instrumented file", action: 'storeTrue'});
parser.addArgument(['--inlineSource'], {help: "Inline original source as string in J$.iids.code in the instrumented file", action: 'storeTrue'});
parser.addArgument(['--astHandlerModule'], {help: "Path to a node module that exports a function to be used for additional AST handling after instrumentation"});
parser.addArgument(['script_and_args'], {
    help: "script to record and CLI arguments for that script",
    nargs: argparse.Const.REMAINDER
});
var args = parser.parseArgs();
var astHandler = null;
if (args.astHandlerModule) {
    astHandler = require(args.astHandlerModule);
}



if (args.script_and_args.length === 0) {
    console.error("must provide script to record");
    process.exit(1);
}
// we shift here so we can use the rest of the array later when
// hacking process.argv; see below
var script = args.script_and_args.shift();
github nodeca / js-yaml / bin / js-yaml.js View on Github external
prog:     'js-yaml',
  version:  require('../package.json').version,
  addHelp:  true
});


cli.addArgument([ '-c', '--compact' ], {
  help:   'Display errors in compact mode',
  action: 'storeTrue'
});


// deprecated (not needed after we removed output colors)
// option suppressed, but not completely removed for compatibility
cli.addArgument([ '-j', '--to-json' ], {
  help:   argparse.Const.SUPPRESS,
  dest:   'json',
  action: 'storeTrue'
});


cli.addArgument([ '-t', '--trace' ], {
  help:   'Show stack trace on error',
  action: 'storeTrue'
});

cli.addArgument([ 'file' ], {
  help:   'File to read, utf-8 encoded without BOM',
  nargs:  '?',
  defaultValue: '-'
});
github twosigma / git-meta / node / lib / cmd / reset.js View on Github external
});

    parser.addArgument(["--hard"], {
        required: false,
        action: "storeConst",
        constant: true,
        help: `Discard all changes and reset both working directory and index \
as specified by the selected commit.`
    });

    parser.addArgument(["commitish"], {
        type: "string",
        help: "commit to reset the head of the current branch to",
        defaultValue: null,
        required: false,
        nargs: ArgParse.Const.OPTIONAL,
    });

    // I want to use `Const.REMAINDER` here, but it doesn't work right; it
    // doesn't show 'path' in the command line list and doesn't behave any
    // differently that `ZERO_OR_MORE`; the `--` doesn't serve to delimit paths
    // from commitishes.

    parser.addArgument(["path"], {
        type: "string",
        help: `\
When paths are provided, git-meta resets the index entries for all  to
their state at . (It does not affect the working tree or the
current branch.)

This means that git meta reset  is the opposite of git meta add
.`,
github wala / jsdelta / src / options.js View on Github external
action: 'storeTrue'
    });
    parser.addArgument(['--optimize'], {
        help: "enable inlining and constant folding (slower, but more optimal)",
        action: 'storeTrue'
    });
    parser.addArgument(['--cmd'], {help: "command to execute on each iteration"});
    parser.addArgument(['--record'], {help: "file to store recording in"});
    parser.addArgument(['--replay'], {help: "file to replay recording from"});
    parser.addArgument(['--errmsg'], {help: "substring in stderr to look for"});
    parser.addArgument(['--msg'], {help: "substring in stdout to look for"});
    parser.addArgument(['--dir'], {help: "directory to reduce (should contain the main file!)"});
    parser.addArgument(['--out'], {help: "directory to move the minimized output to"});
    parser.addArgument(['main-file_and_predicate_and_predicate-args'], {
        help: "main file to reduce, followed by arguments to the predicate",
        nargs: argparse.Const.REMAINDER
    });
    var args = parser.parseArgs();

    var tail = args['main-file_and_predicate_and_predicate-args'];
    var file = tail[0];
    if (!file) {
        parser.printHelp();
        process.exit(-1);
        return;
    }
    var predicate = tail[1];
    var predicateArgs = tail.slice(2);

    options.quick = args.quick;
    options.optimize = args.optimize;
    options.findFixpoint = !options['no-fixpoint'];