Skip to content

Commit e204e28

Browse files
committed
Added support for aliases in exist method.
1 parent d27d7ed commit e204e28

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,16 @@ class Parser {
188188

189189
flag = this.#getFlag(flag)
190190

191-
return this.#flags.has(flag)
191+
if (!this.#flags.has(flag)) {
192+
for (const alias of this.getFlagAliases(flag)) {
193+
if (this.#flags.has(alias)) {
194+
return true
195+
}
196+
}
197+
return false
198+
}
199+
200+
return true
192201
}
193202

194203
require () {
@@ -419,7 +428,7 @@ class Parser {
419428
if (this.#required.size > 0) {
420429
for (let arg of this.#required) {
421430
let flag = this.#getFlag(arg)
422-
431+
423432
if (!this.exists(flag)) {
424433
this.#violations.add(`"${flag}" is a required flag.`)
425434
valid = false

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@author.io/arg",
3-
"version": "1.2.0-beta.1",
3+
"version": "1.2.0",
44
"description": "An argument parser for CLI applications.",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)