Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@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.
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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.