args
TODO .
Command processing
Read system.in (check if there is input piped from other command)
Parse command line tokens into options and positional parameters
Check command line definition for invalid options, etc.
Apply defaults: option defaults, defaults in configuration files -user dir, and current dir-
Check missing options: fail if no interactive, ask for input if interactive
Return result
Support - and --
Take care of environment variables and .env files in current dir
Support interactive settings prompt if mandatory options are missing
Support @files for long list of parameters
Program, can have stream input, config files (XDG dirs), and parameters
Check:
https://clig.dev/#the-basics
https://medium.com/@jdxcode/12-factor-cli-apps-dd3c227a0e46
https://github.com/TeXitoi/structopt
https://github.com/spf13/cobra
https://ajalt.github.io/clikt
https://bloomberg.github.io/stricli/docs/tutorial
Install the Dependency
=== "build.gradle"
```groovy
repositories {
mavenCentral()
}
implementation("com.hexagontk:args:$hexagonVersion")
```
=== "pom.xml"
```xml
com.hexagontk args $hexagonVersion
```
TODO
Know when it is a TTY or not
Handle stdin (pipes)
Load properties from (
./.program.properties
,~/.config/program.properties
)Allow missing options to be searched in System Settings (See Jvm.systemSetting)
Load command line options from files with
@file
parametersAdd color to default formatters, and honor NO_COLOR environment variable
Handle standard options like --help, help command -q --quiet, -v verbose, etc.
Control rendering with flags on
ArgsManager
Check documentation rendering of
http
(httpie) andsdk
(sdkman)Allow interactive commands and options when something is missing
Add command aliases (convert name to a list)
Set default command on program definition (as a list or names to resolve the command)
Add a parameter to fetch parameters from System Properties on missing parameters
Loading of options from files (see below) must be done outside cli processing
'--' stops parsing options and threat everything from that point as positional parameters
Tags can be used to define groups (i.e.: of mutually exclusive options)
Add files and environment variables documentation on the program arguments
Add examples to program documentation
When an option can pick the value from an environment variable, manually load that env into System properties and let the program pick values from there (see above)
Allows to load a parameter from command line, environment variable or a set of files with a priority:
command line
environment variable
java property (only for testing)
$HOME/.config/app/*.{json,yaml}
$HOME/.config/app/*.{json,yaml}
Discoverable CLIs have comprehensive help texts, provide lots of examples, suggest what command to run next, suggest what to do when there is an error. There are lots of ideas that can be stolen from GUIs to make CLIs easier to learn and use, even for power users.
the CLI has embodied an accidental metaphor all along: it’s a conversation.