You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I saw derive code samples like #[command(author, version, about, long_about = None)]
Do we have a command attribute "examples" alongside "author", "version", "about", and etc?
I need to give examples which must begin with the program name.
Currently I use the "after_help" attribute like after_help="Examples: ...."
But I do not know how to dynamically put the program name into the Examples text. I have to hardcode the program name which is not ideal because if I rename the built binary executable, the hardcoded program name will be wrong.
after_help is the recommended way of doing this. We do not have native support for examples. All of the existing attributes you mentioned have had a definitive way of being used but there is a lot of application-specific policy for how to list out examples.
You could use the help_template for this and then use the help template variables to fill in the names. We are unlikely to do anything more than that as normally a program's name is fairly static and the cost of making things more dynamic doesn't seem like it would provide enough benefit for the downsides. Even the help_template, I'd like to find a way to make it more of an optional feature than natively built-in.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I saw derive code samples like
#[command(author, version, about, long_about = None)]
Do we have a command attribute "examples" alongside "author", "version", "about", and etc?
I need to give examples which must begin with the program name.
Currently I use the "after_help" attribute like
after_help="Examples: ...."
But I do not know how to dynamically put the program name into the Examples text. I have to hardcode the program name which is not ideal because if I rename the built binary executable, the hardcoded program name will be wrong.
Beta Was this translation helpful? Give feedback.
All reactions