Wolfram/
CommandLineParser
(1.0.0)
current version: 1.0.2 »
Installation Instructions
To install this paclet in your Wolfram Language environment,
evaluate this code:
PacletInstall["Wolfram/CommandLineParser"]
To load the code after installation, evaluate this code:
Needs["Wolfram`CommandLineParser`"]
Examples
Basic Examples (5)
Specify a command line interface with a single numeric argument:
Parse settings according to the above specification:
ParseCommandLine is meant to be used in Wolfram Language scripts. In the above example command line arguments are explicitly provided as a list of strings, but it's not necessary to do so in a script. When ParseCommandLine is used in a script, its 1-argument form will automatically grab the arguments provided from the command line. When ran from a notebook interface the 1-argument form does not work:
The script equivalent to the above example is:
(* script.m *)
Get[]
argsSpec = {{"my-int-arg" -> NumericSpec["Integer", "An unbounded integer"]}, {}};
parsed = ParseCommandLine[argsSpec];
Print[parsed]The script is called e.g. in this way:
$ math -script script.m 42
{<|"my-int-arg" → 42|>, <||>}Scope (3)
Specify a command line interface with three positional arguments (the last being variadic) and two optional arguments:
Parse various inputs:
If the special flag -- help is passed, an auto-generated help message is printed :
See the Tech Notes for the full documentation
Compatibility
Wolfram Language Version 13.0
Version History
-
1.0.2
– 19 March 2024
-
1.0.1
– 18 March 2024
-
1.0.0
– 18 March 2024
MIT License
Paclet Source