Skip to content
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

Add note to always use positional args first #15761

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions conan/cli/command.py
Expand Up @@ -120,6 +120,12 @@ def parse_args(self, args=None, namespace=None):
self._conan_api.config.global_conf.update_conf_definition(confs)
return args

def format_help(self):
formatted_help = super().format_help()
formatted_help += ("\nNOTE: Use always positional parameters first\n"
" conan <command> <positional args> [optional args]\n")
return formatted_help
Comment on lines +125 to +127
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
formatted_help += ("\nNOTE: Use always positional parameters first\n"
" conan <command> <positional args> [optional args]\n")
return formatted_help
lines = formatted_help.splitlines()
note = ("\nNOTE: Use always positional parameters first\n"
" conan <command> <positional args> [optional args]\n")
lines.insert(lines.index(""), note)
return "\n".join(lines)

I tried it, but I was not convinced, as it shows at the very end, not very visible when there are arguments.
Then I tried this, it seems it would be a bit better IMHO.

Still, it is also missing in the short usage error when some arg is missing or incorrect. This can be solved by adding the format_usage() method too.

All in all, seems a bit too dirty/too much for a known Python bug: python/cpython#53584

Not sure what would be the best approach to be honest.

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's just make sure we mention it somewhere in the docs then!



class ConanCommand(BaseConanCommand):
def __init__(self, method, group=None, formatters=None):
Expand Down