New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

argz-parser

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

argz-parser

A utility module used by CLI tools for parsing arguments. Returns an array of corresponding actions to be taken.

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

Argz-Parser Build Status

A utility module used by CLI tools for parsing arguments. Returns an array of corresponding actions to be taken.

Configuration

This module must be passed a config file in order to parse the arguments.

/*
* Config file for dw cli
*
*/

// Dependencies
const pj = require("./package.json");

module.exports = {
  version: pj.version,
  help: `
    Usage:
    dw [flag]        dw calls the cli options chosen by passing a flag

    Options:
    -i, --init       install a new Devwatch blog in current directory
    -h, --help       print help menu
    -v, --version    print current version of kick-init package
    -w, --watch      watch the project for changes, site recompiles on change

    Examples:
    # creates a new blog in current directory
    $ dw --init
    # Print help menu
    $ dw -h
  `,
  flags: [
    {
      flag: ["-i", "--init"],
      action: "init"
    },
    {
      flag: ["-h", "--help"],
      action: "help"
    },
    {
      flag: ["-v", "--version"],
      action: "version"
    },
    {
      flag: ["-w", "--watch"],
      action: "watch"
    }
  ]
};

Basic Use

Install module by running

$ yarn add argz-parser

or

$ npm -i argz-parser

Then call argz-parser passing in the argument list and the config file. This function will return a promise that resolves into an array of string names representing the actions to be taken.

"use strict";

const path = require("path");
const argzParser = require("argz-parser");
const { init } = require("./lib/dwFunctions");
const config = require("./.dwconfig.js");

module.exports = args => {
  args = typeof args == "object" ? args : false;

  if (args) {
    argzParser(args, config).then(args => {
      args.map(arg => {
        switch (arg) {
          case "init":
            init(path.join(__dirname, "/bin/setUpApp.sh"), process.cwd());
            break;
          case "help":
            console.log(config.help);
            break;
          case "watch":
            console.log("im watching");
            break;
          default:
            console.log(config.version);
        }
      });
    });
  } else {
    throw Error(
      "\x1b[31m%s\x1b[0m",
      "Improper arguments passed to the devwatch cli"
    );
  }
};

Keywords

FAQs

Package last updated on 01 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc