Skip to content

Better usage message in help output#1906

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

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

Conversation

@tmccombs
Copy link
Copy Markdown
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.
Comment thread 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 😕

@tmccombs
Copy link
Copy Markdown
Collaborator Author

Google's documentation style guide for CLIS states

If there's more than one optional argument, enclose each item in its own set of square brackets.

and it is non-standard for how several command line parsing libraries, including clap output option help, so I'm not really sure this is the best change anyway.

In fact, I kind of wonder if it would have been better to just have the base path(s) be specified as an option rather than as a positional argulment. probably too late for that now though.

@tmccombs tmccombs closed this Mar 10, 2026
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