🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

electron-args

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-args

cli helper for electron

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

electron-args Build Status

cli helper for electron

Features

  • Change the argument by the execution environment
  • Parses arguments using minimist
  • Converts flags to camelCase
  • Outputs app version when --version
  • Outputs supplied help text when --help
  • inspired by meow

Install

$ npm install --save electron-args

Usage

const electron = require('electron');
const parseArgs = require('electron-args');

const cli = parseArgs(`
	sample-viewer

	Usage
	  $ sample-viewer [path]

	Options
	  --help     show help
	  --version  show version
	  --auto     slide show [Default: false]

	Examples
	  $ sample-viewer . --auto
	  $ sample-viewer ~/Pictures/
`, {
	alias: {
		h: 'help'
	},
	default: {
		auto: false
	}
});

console.log(cli.flags);
console.log(cli.input[0]);

electron.app.on('ready', () => {
	const win = new electron.BrowserWindow({width: 400, height: 400});
	win.loadURL(`file://${__dirname}/fixture.html`);
});

API

parseArgs(opts, [minimistOptions])

Returns an Object with:

  • input (Array) - Non-flag arguments
  • flags (Object) - Flags converted to camelCase
  • help (string) - The help text used with --help
  • showHelp([code=0]) (Function) - Show the help text and exit with code

options

Type: Object Array string

Can either be a string/array that is the help or an options object.

help

Type: string boolean The help text you want shown.

Set it to false to disable it altogether.

version

Type: string boolean Default: electron.app.getVersion()

Set a custom version output.

Set it to false to disable it altogether.

argv

Type: Array

Custom arguments object.

minimistOptions

Type: Object Default: {}

Minimist options.

Keys passed to the minimist default option are decamelized, so you can for example pass in fooBar: 'baz' and have it be the default for the --foo-bar flag.

License

MIT © akameco

Keywords

electron

FAQs

Package last updated on 22 Aug 2016

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