has-flag

WebJar for has-flag

License

License

MIT
GroupId

GroupId

org.webjars.bowergithub.sindresorhus
ArtifactId

ArtifactId

has-flag
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

has-flag
WebJar for has-flag
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/sindresorhus/has-flag

Download has-flag

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.bowergithub.sindresorhus/has-flag/ -->
<dependency>
    <groupId>org.webjars.bowergithub.sindresorhus</groupId>
    <artifactId>has-flag</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bowergithub.sindresorhus/has-flag/
implementation 'org.webjars.bowergithub.sindresorhus:has-flag:1.0.0'
// https://jarcasting.com/artifacts/org.webjars.bowergithub.sindresorhus/has-flag/
implementation ("org.webjars.bowergithub.sindresorhus:has-flag:1.0.0")
'org.webjars.bowergithub.sindresorhus:has-flag:jar:1.0.0'
<dependency org="org.webjars.bowergithub.sindresorhus" name="has-flag" rev="1.0.0">
  <artifact name="has-flag" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bowergithub.sindresorhus', module='has-flag', version='1.0.0')
)
libraryDependencies += "org.webjars.bowergithub.sindresorhus" % "has-flag" % "1.0.0"
[org.webjars.bowergithub.sindresorhus/has-flag "1.0.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

has-flag

Check if argv has a specific flag

Install

$ npm install has-flag

Usage

// foo.js
import hasFlag from 'has-flag';

hasFlag('unicorn');
//=> true

hasFlag('--unicorn');
//=> true

hasFlag('f');
//=> true

hasFlag('-f');
//=> true

hasFlag('foo=bar');
//=> true

hasFlag('foo');
//=> false

hasFlag('rainbow');
//=> false
$ node foo.js -f --unicorn --foo=bar -- --rainbow

API

hasFlag(flag, argv?)

Returns a boolean for whether the flag exists.

It correctly stops looking after an -- argument terminator.

flag

Type: string

CLI flag to look for. The -- prefix is optional.

argv

Type: string[]
Default: process.argv

CLI arguments.


Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Versions

Version
1.0.0