Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

get-cli-arg

bevry947Artistic-2.08.6.0TypeScript support: included

Get the value of a CLI argument

arg, argument, arguments, argv, cli, deno, deno-edition, deno-entry, denoland, es2022, export-default, node, process.argv, typed, types, typescript

readme

get-cli-arg

Status of the GitHub Workflow: bevry NPM version NPM downloads
GitHub Sponsors donate button ThanksDev donate button Patreon donate button Liberapay donate button Buy Me A Coffee donate button Open Collective donate button crypto donate button PayPal donate button
Discord server badge Twitch community badge

Get the value of a CLI argument

Usage

Complete API Documentation.

Supports fetching the value of an argument with the following convention:

  • --arg => true
  • --arg= => false
  • --arg="string" => "string"
  • --arg={"a":1} => {"a": 1}

Uses normalify for value parsing.

import getarg from 'get-cli-arg'
console.log(getarg('arg'))
console.log(getarg('arg', process.argv))

Install

npm

  • Install: npm install --save get-cli-arg
  • Import: import pkg from ('get-cli-arg')
  • Require: const pkg = require('get-cli-arg').default

Deno

import pkg from 'https://unpkg.com/get-cli-arg@^8.6.0/edition-deno/index.ts'

Editions

This package is published with the following editions:

  • get-cli-arg/source/index.ts is TypeScript source code with Import for modules
  • get-cli-arg aliases get-cli-arg/edition-es2022/index.js
  • get-cli-arg/edition-es2022/index.js is TypeScript compiled against ES2022 for Node.js 8 || 10 || 12 || 14 || 16 || 18 || 20 || 21 with Require for modules
  • get-cli-arg/edition-es2022-esm/index.js is TypeScript compiled against ES2022 for Node.js 12 || 14 || 16 || 18 || 20 || 21 with Import for modules
  • get-cli-arg/edition-types/index.d.ts is TypeScript compiled Types with Import for modules
  • get-cli-arg/edition-deno/index.ts is TypeScript source code made to be compatible with Deno

History

Discover the release history by heading on over to the HISTORY.md file.

Backers

Code

Discover how to contribute via the CONTRIBUTING.md file.

Authors

Maintainers

Contributors

Finances

GitHub Sponsors donate button ThanksDev donate button Patreon donate button Liberapay donate button Buy Me A Coffee donate button Open Collective donate button crypto donate button PayPal donate button

Sponsors

  • Andrew Nesbitt — Software engineer and researcher
  • Balsa — We're Balsa, and we're building tools for builders.
  • Codecov — Empower developers with tools to improve code quality and testing.
  • Poonacha Medappa
  • Rob Morris
  • Sentry — Real-time crash reporting for your web apps, mobile apps, and games.
  • Syntax — Syntax Podcast

Donors

License

Unless stated otherwise all works are:

and licensed under:

changelog

History

v8.6.0 2023 December 30

v8.5.0 2023 December 27

v8.4.0 2023 December 6

v8.3.0 2023 November 25

v8.2.0 2023 November 23

v8.1.0 2023 November 15

v8.0.0 2023 November 14

  • Updated dependencies, base files, and editions using boundation
  • Minimum required Node.js version changed from node: >=10 to node: >=8 adapting to ecosystem changes

v7.4.0 2023 November 1

v7.3.0 2021 July 30

v7.2.0 2021 July 29

v7.1.0 2021 July 28

v7.0.0 2021 June 14

  • Fixes a bug where if say arguments a and ab are present, and you want to fetch argument a, the value of ab could be returned
  • Supports arguments which values are separated from the key via any whitespace character
  • Updated dependencies, base files, and editions using boundation

v6.8.0 2020 October 29

v6.7.0 2020 September 4

v6.6.0 2020 August 18

v6.5.0 2020 August 4

v6.4.0 2020 July 22

v6.3.0 2020 July 22

v6.2.0 2020 July 21

v6.1.0 2020 June 25

v6.0.0 2020 June 25

  • Only support arguments that are prefixed with -- or --no-
  • Added support for --no- inversion
  • Updated dependencies, base files, and editions using boundation

v5.8.0 2020 June 21

v5.7.0 2020 June 21

v5.6.0 2020 June 20

v5.5.0 2020 June 10

v5.4.0 2020 June 10

v5.3.0 2020 May 22

v5.2.0 2020 May 21

v5.1.0 2020 May 13

v5.0.0 2020 May 6

  • Backwards Compatibility Break: Changed the argument order, so now you only have to specify an argument name, and optionally the argument list

v4.6.0 2020 May 6

v4.5.0 2020 May 6

v4.4.0 2020 May 6

v4.3.0 2020 May 6

v4.2.0 2020 May 6

v4.1.0 2020 May 4

v4.0.0 2020 March 26

  • Updated dependencies, base files, and editions using boundation
  • Minimum required node version changed from node: >=8 to node: >=10 to keep up with mandatory ecosystem changes

v3.0.0 2019 December 18

v2.3.0 2019 December 9

v2.2.0 2019 December 1

v2.1.0 2019 December 1

v2.0.0 2019 November 18

  • Updated dependencies, base files, and editions using boundation
  • Minimum required node version changed from node: >=10 to node: >=8 to keep up with mandatory ecosystem changes

v1.1.0 2019 November 13

v1.0.0 2019 November 10

  • Initial working commit