JSPM

electron-args

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 155
  • Score
    100M100P100Q80768F
  • License MIT

cli helper for electron

Package Exports

  • electron-args

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (electron-args) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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