Describe the bug

When using the cli's hints, optional arguments (e.g. [arg]) are always shown, but not hidden if used.

To reproduce

Fire up the cli and start typing a command with optional arguments (e.g. SET)

Expected behavior

cli tips should hide an optional argument once used.

Additional information

None

Comment From: oranagra

While at it, try to handle other non-trivial command arguments, like nested blocks, and | options (subcommands and such)

Comment From: huangzhw

I found it's really difficult to do this. AUTH [username] password you never know second is username or password. BRPOP key [key ...] timeout you never know when key ends. ...

Comment From: oranagra

for these cases we obviously can't tell, and we should just make some assumption. e.g. for BLPOP it can keep suggesting to add more keys (and a timeout). for it can assume you provided a user name and suggest you add a password. either way, handling these badly probably won't be worse than what we do now, so we can at least attempt to better handle the ones that are possible to solve better.

Comment From: jhelbaum

It's not clear to me what the desired behavior is here. If I'm not mistaken, currently the hints engine only knows how many arguments were passed. It has no way of associating specific args with specific options. It can't even tell whether an argument is meant to be a literal or not - the help syntax doesn't distinguish between them. (And some literal args appear in uppercase but others are lowercase.)

LPOS key element [RANK rank] [COUNT num-matches] [MAXLEN len]

The hinter would need to know that RANK, COUNT and MAXLEN are literal. (Does the order between them matter? The command implementation doesn't think so. How would the hinter know?)

Solving this problem may require enhancing the help syntax, or augmenting it with metadata.

Comment From: jhelbaum

Playing with the CLI, I found another bug. The hints don't work for two-word commands. It may be that the second word of the command is treated as the first word of the argument list, but in any case it doesn't work right.

Try, for example:

ACL DELUSER username [username ...]

CLIENT PAUSE timeout [WRITE|ALL]

CONFIG SET parameter value

And when the argument list starts with an optional parameter, it fails differently - the hint disappears after a space is typed:

CLUSTER RESET [HARD|SOFT]

CLIENT KILL [ip:port] [ID client-id] [TYPE normal|master|slave|pubsub] [USER username] [ADDR ip:port] [LADDR ip:port] [SKIPME yes/no]

Summary: The current hints mechanism is very rudimentary, and is easily confused by many nontrivial situations, including optional arguments, repeated arguments and two-word commands. If we want it to be useful, it needs a significant rethinking.

Comment From: huangzhw

@jhelbaum What you said maybe fixed by https://github.com/redis/redis/pull/8914.

Comment From: jhelbaum

You're right. Thanks for pointing that out.

On Mon, Jul 26, 2021, 04:32 Huang Zhw @.***> wrote:

@jhelbaum https://github.com/jhelbaum What you said maybe fixed by #8914 https://github.com/redis/redis/pull/8914.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/redis/redis/issues/8084#issuecomment-886307201, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH5PZMJ6PW4L5QPP7DHFT5TTZS3JFANCNFSM4T7XWKUQ .

Comment From: jhelbaum

I wasn't running the latest code.

Comment From: oranagra

handled by #10515