
Security News
Python Adopts Standard Lock File Format for Reproducible Installs
Python has adopted a standardized lock file format to improve reproducibility, security, and tool interoperability across the packaging ecosystem.
@hypernym/args
Advanced tools
A fast and ultra lightweight CLI argument parser.
Repository ✦ Package ✦ Releases ✦ Discussions
pnpm add @hypernym/args
Unprefixed inputs are stored in an array.
$ arg
# => { _: ['arg'] }
$ arg-a arg-b arg-c
# => { _: ['arg-a', 'arg-b', 'arg-c'] }
Inputs with --
prefix are parsed as flags.
By default, standalone flags with no value are defined as true
.
$ --flag
# => { _: [], flag: true, }
$ --flag value
# => { _: [], flag: 'value', }
$ --flag=value
# => { _: [], flag: 'value', }
Inputs with -
prefix are parsed as aliases.
By default, standalone aliases with no value are defined as true
.
$ -alias
# => { _: [], alias: true, }
$ -alias value
# => { _: [], alias: 'value', }
$ -alias=value
# => { _: [], alias: 'value', }
--
and -
=
$ arg=value -- arg-b=value -
# => { _: [] }
$ hello world --foo bar -baz -cli demo --fuz
import { createArgs } from '@hypernym/args'
interface Args {
foo?: string
baz?: boolean
cli?: string
fuz?: boolean
}
const args = createArgs<Args>()
console.log(args)
/*
{
_: ['hello', 'world'],
foo: 'bar',
baz: true,
cli: 'demo',
fuz: true
}
*/
Specifies an array of values to parse as arguments.
string[] | undefined
process.argv.slice(2)
import { createArgs } from '@hypernym/args'
createArgs({
argv: process.argv.slice(2),
})
Specifies an object of alias
that will be added to the parsed output with matching values.
Record<string, string | string[]> | undefined
undefined
import { createArgs } from '@hypernym/args'
createArgs({
alias: {
config: ['conf', 'c'],
help: 'h',
},
})
Specifies an object of defaults
that will be added to the parsed output regardless of CLI
inputs.
(Record<string, unknown> & { _?: string[] }) | undefined
undefined
import { createArgs } from '@hypernym/args'
createArgs({
defaults: {
_: ['value'],
a: true,
},
})
Specifies an array of values that will be skipped when parsing arguments.
string[] | undefined
undefined
import { createArgs } from '@hypernym/args'
createArgs({
exclude: ['arg', '--flag', '-alias'],
})
Feel free to ask questions or share new ideas.
Use the official discussions to get involved.
Developed in 🇭🇷 Croatia, © Hypernym Studio.
Released under the MIT license.
FAQs
A fast and ultra lightweight CLI argument parser.
The npm package @hypernym/args receives a total of 5 weekly downloads. As such, @hypernym/args popularity was classified as not popular.
We found that @hypernym/args demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Python has adopted a standardized lock file format to improve reproducibility, security, and tool interoperability across the packaging ecosystem.
Security News
OpenGrep has restored fingerprint and metavariable support in JSON and SARIF outputs, making static analysis more effective for CI/CD security automation.
Security News
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.