![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Straightforward and typesafe command-line argument parsing with subcommands.
Straightforward and type-safe command-line argument parsing with subcommands.
import { createCLICommand, validate, logger, runThenExitIfMain, runCommand } from '@jitl/cli'
export const command = createCLICommand({
description: `Say hello`,
flags: {
name: {
description: `What name should we greet?`,
validate: validate.string(),
},
exuberant: {
description: `Are we excited?`,
validate: validate.boolean(),
default: () => false,
},
},
async run({ name, exuberant }) {
logger.log(`Hello, ${name}. Nice to see you today${exuberant ? '!' : '.'}`)
},
})
runThenExitIfMain(module, (name, argv) => runCommand(name, command, argv))
Type-safe without stuttering.
While existing libraries offer typings via @types/...
packages, few infer
the arguments of the run()
function of a command from the parameters.
The parameters of the run(flags, args, rest)
function are completely inferred
from the runtime type specification, so your CLI command declarations are
succinct and readable.
Library, not a framework.
Existing Typescript frameworks like oclif force a specific setup, and
contain many layers of abstraction between invocation and your run()
function.
This package offers flexibility through composition, rather than a complex "plug-ins" or "hooks" interface.
Usable conventions. Many command-line frameworks follow typical Unix conventions, which are suitable for experts, but provide a poor user experience for casual CLI users.
Prefer long (GNU-style) named flags like --bool
| --value given-value
.
Removes mental burden of argument order, and makes reading your shell history
more clear.
Positional arguments are still available for glob-related use-cases.
Prompt users for missing required arguments. Don't kick the user and force them to read the help.
Bike-shedding. There are many command-line frameworks out there. It's easy to be opinionated about the "mistakes" (choices) a CLI framework makes.
Because this package is short, has a flat dependency graph, and favors composition over hooks/plugins/inheritance, it's easy to replace, wrap, extend, smoosh, and make it your own.
This package only imports its dependencies when they are needed for a specific purpose.
chalk
: imported when displaying help output. Used to bold text, which has a nice
appearance.
table
: imported when displaying help output. Used to format the table of
flags, etc.
fs-extra
: imported when loading a directory of subcommands. Used to scan a
directory for subcommand files. For better performance and type-safety, but
also more boilerplate, consider manually constructing a CommandLoaders
object.
inquirer
: imported when a user fails to provide a required argument. Used
to interactively prompt the user for the needed value.
In short, this package never imports a dependency on the happy path to run a fully-specified command.
For now, you'll need to read the code.
Design modifications for the Command
interface to allow nesting subcommands
easily without custom code. Currently, because we throw if an unknown flag is
given, a standard CLI command cannot dispatch to subcommands unless they both
share the same flags.
An elegant design would allow for arbitrary nesting of commands and subcommand loaders.
The current validate: Validator<T>
interface is not introspectable at runtime,
which limits the usefulness and accuracy of help messages for an argument.
All we can show to guide the user is the default value.
A usable system should be able to infer specific syntax based on the type of the flag.
Documentation.
It should be auto-generated from TSDoc comments in the source.
Examples for subcommands.
This should go in the ./examples directory.
Tests.
Ah, tests.
FAQs
Straightforward and typesafe command-line argument parsing with subcommands.
The npm package @jitl/cli receives a total of 1 weekly downloads. As such, @jitl/cli popularity was classified as not popular.
We found that @jitl/cli demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.