How to use node-getopt - 10 common examples

To help you get started, we’ve selected a few node-getopt 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 graphql-factory / graphql-factory / test / index.js View on Github external
var chai = global.chai = require('chai')
var rewire = global.rewire = require('rewire')
var graphql = global.graphql = require('graphql')
var private = global.private = rewire('../index')
var factory = global.factory = require('../index')(graphql)
var expect = global.expect = chai.expect
var utils = require('./utils')

global.logger = {
  error: function (log) {
    console.log(log)
  }
}

var opt = require('node-getopt').create([
  ['t', 'test=ARG', 'tests to run using comma separated']
]).bindHelp().parseSystem()

// include tests
var unitTests = require('./unit')

// get tests to run
var tests = (opt.options.test || 'all').split(',')

// run appropriate tests
if (utils.hasTest(tests, /^unit/)) unitTests(tests)
github evoldoers / machineboss / js / lib / testcompiledprof.js View on Github external
#!/usr/bin/env node

var fs = require('fs'),
    path = require('path'),
    Getopt = require('node-getopt'),
    sp = require('./softplus'),
    getParams = require('./getparams')

var getopt = Getopt.create([
  ['p' , 'params=FILE'      , 'specify parameters as JSON file'],
  ['x' , 'inprof=FILE'      , 'specify input profile as CSV file'],
  ['y' , 'outprof=FILE'     , 'specify output profile as CSV file'],
  ['i' , 'inseq=STRING'     , 'specify input sequence as string'],
  ['o' , 'outseq=STRING'    , 'specify output sequence as string'],
  ['h' , 'help'             , 'display this help message']
])              // create Getopt instance
.bindHelp()     // bind option 'help' to default action
var opt = getopt.parseSystem() // parse command line

var input, output, params

function readCSV (filename) {
  var rows = fs.readFileSync(filename).toString().split('\n').filter (function (line) { return line.length }).map (function (line) { return line.split(',') })
  return { header: rows[0], row: rows.slice(1).map (function (row) { return row.map (parseFloat) }) }
}
github 4minitz / 4minitz / tests / performance / createMinutesData.js View on Github external
"use strict";

let mongo = require('mongodb').MongoClient,
    random = require('randomstring'),
    faker = require('faker'),
    fs = require('fs'),
    optionParser = require('node-getopt').create([
        ['c', 'customize=[ARG]', 'file to customize the data generation process'],
        ['m', 'mongourl=[ARG]', 'Mongo DB url'],
        ['h', 'help', 'Display this help']
    ]);

let arg = optionParser.bindHelp().parseSystem();

// check preconditions
// we need a mongo url, first check environment variables, then
// parameters and if neither provides a url, exit with an error

let mongoUrl = arg.options.mongourl || process.env.MONGO_URL;

if (!mongoUrl) {
    optionParser.showHelp();
    console.error('No mongo url found in env or given as parameter.');
github asmblah / jemul8 / tests / bdd / index.js View on Github external
(function () {
    "use strict";

    var modular = require("modular-amd"),
        optionsManager = require("node-getopt").create([
            ["g", "grep=
github santoshrajan / lispyscript / lib / lispy.js View on Github external
// Generated by LispyScript v1.0.0
require("./require");
var fs = require("fs"),
    path = require("path"),
    ls = require("./ls"),
    repl = require("./repl"),
    watch = require("watch"),
    isValidFlag = /-h\b|-r\b|-v\b|-b\b|-s\b/,
    error = function(err) {
        console.error(err.message);
        return process.exit(1);
    };
var opt = ((((require('node-getopt')).create([['h', 'help', 'display this help'],
    ['v', 'version', 'show version'],
    ['r', 'run', 'run .ls files directly'],
    ['w', 'watch', 'watch and compile changed files beneath current directory'],
    ['b', 'browser-bundle', 'create browser-bundle.js in the same directory'],
    ['m', 'map', 'generate source map files'],
    ['i', 'include-dir=ARG+', 'add directory to include search path']])).setHelp(("lispy [OPTION] [] []\n\n" + " will default to  with '.js' extension\n\n" + "Also compile stdin to stdout\n" + "eg. $ echo '(console.log \"hello\")' | lispy\n\n" + "[[OPTIONS]]\n\n"))).bindHelp()).parseSystem();
(function(___monad) {
    var mBind = ___monad.mBind,
        mResult = ___monad.mResult,
        mZero = ___monad.mZero,
        mPlus = ___monad.mPlus;
    var ____mResult = function(___arg) {
        return (((typeof(___arg) === "undefined") && (!(typeof(mZero) === "undefined"))) ?
            mZero :
            mResult(___arg));
    };
github evoldoers / machineboss / src / nano / node / events2model.js View on Github external
#!/usr/bin/env node

var getopt = require('node-getopt')
var negbin = require('./negbin')
var fast5 = require('./fast5')

var defaultStrand = 0
var defaultKmerLen = 6
var defaultComponents = 1

var minFracInc = 1e-5  // minimum fractional increment for EM negative binomial fit
var minExtendProb = 1e-10

var parser = getopt.create([
  ['f' , 'fast5=PATH'      , 'FAST5 input file'],
  ['s' , 'strand=N'        , 'strand (0, 1, 2; default ' + defaultStrand + ')'],
  ['g' , 'group=GROUP'     , 'group name (000, RN_001, ...)'],
  ['k' , 'kmerlen=N'       , 'kmer length (default ' + defaultKmerLen + ')'],
  ['c' , 'components=N'    , 'negative binomial mixture components (default ' + defaultComponents + ')'],
  ['a' , 'aggregate'       , 'give all kmers the same length distribution'],
  ['h' , 'help'            , 'display this help message']
])              // create Getopt instance
.bindHelp()     // bind option 'help' to default action
var opt = parser.parseSystem(); // parse command line

function inputError(err) {
  parser.showHelp()
  console.warn (err, "\n")
  process.exit(1)
}
github evoldoers / machineboss / src / nano / node / compare.js View on Github external
#!/usr/bin/env node

var getopt = require('node-getopt')
var fasta = require('bionode-fasta')
var colors = require('colors')
var fast5 = require('./fast5')

var defaultStrand = 0
var matchScore = +5, mismatchScore = -4, gapScore = -7

var parser = getopt.create([
  ['q' , 'query=PATH'      , 'FASTA query file'],
  ['r' , 'reference=PATH'  , 'FAST5 reference file'],
  ['s' , 'strand=N'        , 'strand (0, 1, 2; default ' + defaultStrand + ')'],
  ['g' , 'group=GROUP'     , 'group name (000, RN_001, ...)'],
  ['h' , 'help'            , 'display this help message']
])              // create Getopt instance
.bindHelp()     // bind option 'help' to default action
var opt = parser.parseSystem(); // parse command line

function inputError(err) {
  parser.showHelp()
  console.warn (err, "\n")
  process.exit(1)
}

var queryFilename = opt.options.query || inputError("Please specify a query file")
github realm / my-first-realm-app / node / SyncIntro / index.js View on Github external
// the data model
const ItemSchema = {
    name: 'Item',
    primaryKey: 'itemId',
    properties: {
        'itemId': { type: 'string', optional: false },
        'body': { type: 'string', optional: false },
        'isDone': { type: 'bool', optional: false },
        'timestamp': { type: 'date', optional: false }
    }
};


// parsing command-line options
let getopt = require('node-getopt').create([
    [ 'c', 'create=ARG', 'create a new item' ],
    [ 'l', 'list',       'list all items' ],
    [ 'm', 'mark=ARG',   'mark a item done' ],
    [ 'h', 'help',       'display this text'],
]).bindHelp();
let opt = getopt.parse(process.argv.slice(2));

// open the Realm and perform operations
Realm.Sync.User.login(`https://${SERVER}`, USERNAME, PASSWORD)
    .then(user => {
        console.log(`${USERNAME} is logged in`);
        Realm.open({
            sync: {
                url: `realms://${SERVER}/~/todo`,
                user: user
            },
github microsoft / azure-pipelines-agent / release / createReleaseBranch.js View on Github external
const fs = require('fs');
const path = require('path');
const tl = require('azure-pipelines-task-lib/task');
const util = require('./util');

const { Octokit } = require("@octokit/rest");

const OWNER = 'microsoft';
const REPO  = 'azure-pipelines-agent';
const GIT = 'git';
const VALID_RELEASE_RE = /^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/;
const octokit = new Octokit({}); // only read-only operations, no need to auth

process.env.EDITOR = process.env.EDITOR === undefined ? 'code --wait' : process.env.EDITOR;

var opt = require('node-getopt').create([
    ['',  'dryrun',               'Dry run only, do not actually commit new release'],
    ['',  'derivedFrom=version',  'Used to get PRs merged since this release was created', 'latest'],
    ['',  'branch=branch',        'Branch to select PRs merged into', 'master'],
    ['h', 'help',                 'Display this help'],
  ])
  .setHelp(
    'Usage: node createReleaseBranch.js [OPTION] \n' +
    '\n' +
    '[[OPTIONS]]\n'
  )
  .bindHelp()     // bind option 'help' to default action
  .parseSystem(); // parse command line

async function verifyNewReleaseTagOk(newRelease)
{
    if (!newRelease || !newRelease.match(VALID_RELEASE_RE) || newRelease.endsWith('.999.999'))
github evoldoers / machineboss / js / restrict.js View on Github external
#!/usr/bin/env node
// emacs mode -*-JavaScript-*-

// An automata that echoes all DNA sequences except those matching a pattern.

var fs = require('fs'),
    getopt = require('node-getopt')

// parse command-line options
var opt = getopt.create([
  ['m' , 'motif=SEQ'        , 'specify motif [ACGTN]+'],
  ['f' , 'forward'          , 'do not check reverse strand'],
  ['r' , 'repeats'          , 'allow homopolymer repeats'],
  ['h' , 'help'             , 'display this help message']
])              // create Getopt instance
    .bindHelp()     // bind option 'help' to default action
    .parseSystem() // parse command line

var motif = opt.options.motif || 'Z', forward = opt.options.forward, repeats = opt.options.repeats
var motifSeq = motif.toUpperCase().split('')

// The state space is indexed (P,M[1],M[2]...M[motif.length-1])
// where
//  P is the previous nucleotide (or the empty string if in the initial state),
//  M[K] is a binary variable that is true iff the previously-emitted K symbols match the first K characters of the motif.
// We only need to keep 2^(motif.length-1) states because the last bit is never allowed to be 1.

node-getopt

featured command line args parser

MIT
Latest version published 7 years ago

Package Health Score

47 / 100
Full package analysis

Popular node-getopt functions