Skip to content

make matching case-insensitive on zulip #2115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2025

Conversation

jdonszelmann
Copy link
Contributor

I often use work show from my phone, which automatically capitalizes the first letter in my sentence. I see no reason why we would care about case in these commands, so just converting everything to lowercase shouldn't make a difference to most people while it makes the bot do the right thing more often.

@jdonszelmann
Copy link
Contributor Author

jdonszelmann commented Jul 17, 2025

let me know if this makes sense, I thought I wouldn't open an issue since it's such a small change, just making the changes and discussing it here made more sense to me :)

@Urgau
Copy link
Member

Urgau commented Jul 17, 2025

I don't think we currently have any zulip commands that cares about it's argument capitalization, so this would be technically fine.

I still wonder if it wouldn't be better to only lowercase the very first letter of the command.

cc @Kobzol

@jdonszelmann
Copy link
Contributor Author

We currently do not, though I just realized that commands that take parameters probably shouldn't get their parameter lowercased. So maybe we should also only do the first word in the arguments, or only do so after the unchanged version failed to parse

@Urgau
Copy link
Member

Urgau commented Jul 17, 2025

So maybe we should also only do the first word in the arguments, or only do so after the unchanged version failed to parse

Both make sense to me. The first one would be simpler to implement.

@Kobzol
Copy link
Member

Kobzol commented Jul 17, 2025

I think that most of our parameters should already be case resistant. But wouldn't using this: https://docs.rs/clap/latest/clap/struct.Arg.html#method.ignore_case be less of a hack?

@Urgau
Copy link
Member

Urgau commented Jul 17, 2025

I didn't knew about that setting, it indeed seems much better.

@Kobzol
Copy link
Member

Kobzol commented Jul 17, 2025

Sadly AFAIK it cannot be currently applied to the whole command, so we need to add it to each argument separately...

@jdonszelmann
Copy link
Contributor Author

I looked for that but didn't find it earlier. Would be nice to apply globally ye...

@Urgau
Copy link
Member

Urgau commented Aug 6, 2025

@jdonszelmann still interested in this change? if not I can do the change with clap ;)

@jdonszelmann
Copy link
Contributor Author

Am interested, just didn't have time. Go right ahead and feel free to r me for review?

@Urgau
Copy link
Member

Urgau commented Aug 6, 2025

Hum, ignore_case is only defined for arguments (name or value) but not for commands and sub-commands, which isn't really useful for us.

Looking around at other command line parser I haven't found any of them who support case insensible commands.

Least bad way might be to just eat it and use to_lowercase on part of the input command, maybe until the first space.

@Urgau
Copy link
Member

Urgau commented Aug 7, 2025

I think using to lower makes most sense

That's what I meant (us ignoring the casing).

otherwise a pr to clap

That could do it as well, but it's more involved (if even accepted by clap maintainers).

@Urgau
Copy link
Member

Urgau commented Aug 11, 2025

After some back and forth with the clap maintainer in clap-rs/clap#6097 about adding an ignore case for commands, the clap maintainer is proposing a workaround where we add aliases for each commands with the first letter upper-cased.

I think only having the first letter upper-cased would still work for us given how mobile phone keyboards work. That means both whoami and Whoami would match, but not wHoami.

We would use the newly added Command::mut_subcommands method so we wouldn't have to do it manually. The example of that method is roughtly the implementation that we would want.

What do you think @jdonszelmann?

@jdonszelmann
Copy link
Contributor Author

Seems reasonable to me? Neat, thanks for looking into this :3

@Urgau Urgau force-pushed the case-insensitive-zulip branch from a735df1 to 20f335f Compare August 11, 2025 22:10
@Urgau
Copy link
Member

Urgau commented Aug 11, 2025

I have updated your PR to make use of the proposed workaround, which work fine.

@Urgau Urgau requested a review from Kobzol August 11, 2025 22:12
Copy link
Member

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a pretty cool solution :)

@Urgau Urgau added this pull request to the merge queue Aug 12, 2025
Merged via the queue into rust-lang:master with commit d429763 Aug 12, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants