default
Type members
Inherited classlikes
A simple command line argument parser.
A simple command line argument parser.
Usage:
-
Define parameters with param, requiredParam, repeatedParam and command. Each of these methods gives back a handle to a future argument value.
-
Call
parse()
with actual arguments. -
If parsing succeeds, the arguments will be available in the handles defined in step 1.
If parsing fails, error descriptions are printed and the program exits with 2.
Example:
val parser = argparse.ArgumentParser("0.1.0")
val p1 = parser.param[String]("--this-is-a-named-param", default = "default value")
val p2 = parser.param[Int]("positional-param", default = 2)
parser.parse(Seq("--this-is-a-named-param=other", 5))
println(p1.value)
println(p2.value)
- Value parameters:
- description
A short description of this command. Used in help messages.
- enableBashCompletionFlag
Include a
--bash-completion
flag which generate a bash completion script.- enableHelpFlag
Include a
--help
flag which will print a generated help message.- env
The environment.
- stdout
The standard error stream.
- Inherited from:
- ParsersApi
A typeclass that defines how to convert a string from a single command line argument to a given type.
A typeclass that defines how to convert a string from a single command line argument to a given type.
- Inherited from:
- TypesApi
- Inherited from:
- SettingApi
Mark a method as an application entrypoint.
Mark a method as an application entrypoint.
This will generate a main method, which will call the annotated method after parsing the command line.
The mapping between the CLI arguments to the annotated method is as follows:
| Parameter Type | Has Default Value? | CLI +----------------+--------------------+----- | Boolean | yes | --named flag | Boolean | no | positional | Iterable[A] | yes | --named repeated parameter | Iterable[A] | no | positional repeated paramater | A | yes | --named parameter | A | no | positional paramter
These mappings can be overridden by defining custom ParamBuilders.
- Inherited from:
- MainArgsApi
Inherited types
Value members
Inherited methods
The name of the flag to use for generating standalone bash-completion.
The name of the flag to use for generating standalone bash-completion.
Set this to the empty string to disable bash-completion entirely.
- Inherited from:
- ParsersApi
Check the style of parameters.
Check the style of parameters.
This is intended to nudge developers into building command line applications that integrate seamlessly into other system utilities and provide a pleasant user experience.
This is subjective, and you may disable style-checking by overriding this method.
- Inherited from:
- ParsersApi
Generate a main method for a single entry point.
Generate a main method for a single entry point.
This method will become obsolete once annotation macros become available in scala 3.
- Inherited from:
- MainArgsApi
Generate a help message from parameters.
Generate a help message from parameters.
This message will be used by ArgumentParser
s. Overriding this allows you
to customize the help message of all ArgumentParser
s.
- Inherited from:
- ParsersApi
- Inherited from:
- SettingApi
Extension to reader
Extension to reader
- Inherited from:
- SettingApi
Inherited fields
Givens
Inherited givens
- Inherited from:
- MainArgsApi
- Inherited from:
- ArgparseParams
- Inherited from:
- ArgparseReaders
Implicits
Inherited implicits
- Inherited from:
- LowPrioReaders
- Inherited from:
- ReadersApi
- Inherited from:
- ReadersApi
- Inherited from:
- ReadersApi
- Inherited from:
- ReadersApi
- Inherited from:
- ReadersApi
- Inherited from:
- ReadersApi