Enforce at least one argument in commands
See original GitHub issueVariadic arguments are heavily used in the package. However, I think the way they are written now is quite error-prone. For example del
https://github.com/denolib/deno-redis/blob/4ad600278d9c6aeccbbf624eb2593d895ebb9e1c/command.ts#L50
and most other commands require at least one argument. However, with the way the function is written above it’s easy to call del() without any arguments, and an error is thrown. It can be instead written like this, which is semantically similar but safer.
del(key: string, ...keys: string[]): Promise<Integer>;
Thoughts welcome!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Python argparse: Make at least one argument required
The program is meaningless without at least one parameter. How can I configure argparse to force at least one parameter to be chosen?...
Read more >Adding arguments and options to your Bash scripts - Red Hat
First, add a variable and initialize it. Add the two lines shown in bold in the segment of the program shown below. This...
Read more >Python Command Line Arguments
Python command line arguments are the key to converting your programs into useful and enticing tools that are ready to be used in...
Read more >A Simple Guide To Command Line Arguments With ArgParse
Each one of these commands requires a unique set of arguments, and subparsers allow you to distinguish between them. This last example describes ......
Read more >argparse — Parser for command-line options, arguments and ...
The add_argument() method must know whether an optional argument, like -f or --foo , or a positional argument, like a list of filenames,...
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

Good point. Not being able to use spread is quite painful. The error being thrown was the reason I opened this issue, I thought we could leverage type checking to protect users from themselves. But seeing that it’s actually expected behavior in other packages, maybe we should follow the crowd here.
PS) On second thought, I think the current behavior is not wrong 🤔
Reason 1: There may be a situation where users want to use an array
Reason 2: Some other clients behave the same way as this module
For example, go-redis, ioredis, and redis-cli gives the same error when no key passed:
go-redis
main.go
ioredis
index.js