Add .types() for command arguments
See original GitHub issueCommand arguments are automatically assigned a type but there doesn’t seem to be any support for explicit typing like with options. When entering in a phone number with special characters like so:
vorpal.command("send <number> <message>")
app$ send +1212345678 "hello world"
the argument “number” is converted to a number, omitting the + symbol. Furthermore, I think the .types() function available for options should also support command arguments.
Issue Analytics
- State:
 - Created 7 years ago
 - Reactions:5
 - Comments:6 (3 by maintainers)
 
Top Results From Across the Web
Adding arguments and options to your Bash scripts
Bash uses a tool called positional parameters to provide a means of entering data into a Bash program when it is invoked from...
Read more >Command CLI Arguments - Typer - tiangolo
Typer, build great CLIs. Easy to code. Based on Python type hints.
Read more >argparse — Parser for command-line options, arguments and ...
The ArgumentParser object will hold all the information necessary to parse the command line into Python data types. Adding arguments¶. Filling an ArgumentParser ......
Read more >Understanding Command Line Arguments and How to Use ...
Command line arguments are extra commands you can use when launching a program so that the program's functionality will change.
Read more >Command line arguments in C/C++
The most important function of C/C++ is main() function. It is mostly defined with a return type of int and without parameters :...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Greetings to everyone having this issue.
I’ve discovered a way to make params be parsed as strings. Hopefully this will be useful to someone. Note: This enables such behavior per-command and parses ALL arguments(non-options) as strings.
So the solution is - add
"_"to yourstringtypes by calling.types({string: ['_']}). This has to be done PER-COMMAND for those commands in which you want arguments to be parsed as strings.Examples:
If you already have
.types()call add"_"to its “string”:If you don’t have
.types()call, make new one with"_"in “string”:Documentation on .types()
Same for me. Is there any workaround? I’m having problems with hex strings such as:
"0x4e47e95247a535d9c1ed9e5a73f1344a5d864383"Being converted to a number:4.469049581943643e+47The only alternative is to use a
typewith anoptionbut this is a little awkward for the CLI I’m working on.The conversion seems to be from the dep
minimisthere: https://github.com/dthree/vorpal/blob/master/lib/util.js#L33And via minimist, anything not flagged with an option flag that may be a number according to the regex is converted:
https://github.com/substack/minimist/blob/master/index.js#L186