Skip to content

Better usage message in help output#1906

Open
tmccombs wants to merge 2 commits intosharkdp:masterfrom
tmccombs:better-usage
Open

Better usage message in help output#1906
tmccombs wants to merge 2 commits intosharkdp:masterfrom
tmccombs:better-usage

Conversation

@tmccombs
Copy link
Collaborator

@tmccombs tmccombs commented Mar 7, 2026

Improve the usage message to better indicate that the path is optional, but must come after a pattern.

Improve the usage message to better indicate that the path is optional,
but must come after a pattern.
src/cli.rs Outdated
after_long_help = "Bugs can be reported on GitHub: https://github.com/sharkdp/fd/issues",
max_term_width = 98,
args_override_self = true,
override_usage = "fd [OPTIONS] [pattern [path]...]",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My one concern here, is that if the command is fdfind instead, the help output will still say fd.

I'm not really sure how to get around that though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You could just grab std::env::args()[0]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, I'm not sure if that would work in the macro, but could probably be done with the api

Copy link
Collaborator Author

@tmccombs tmccombs Mar 8, 2026

Choose a reason for hiding this comment

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

ok 1ea3719 does that. But it has a different issue where if you invoke it with something like target/debug/fd it will use the full path instead of just fd. I'm not sure which is worse. I could maybe try and figure out just the basename, but that makes this more complicated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

and that makes tests more complicated 😕

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.

2 participants