-
Notifications
You must be signed in to change notification settings - Fork 75
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
Rewrite the CLI module using OO, and organize argparse #3175
Conversation
PR ChecklistHow to use this checklistHow to use this checklistPR AuthorFor each section, check a box when it is true. PR ReviewerCheck that the PR checklist action did not fail. Bug ReferencesNone. Confirm
How to properly reference fixed bugs
Test UpdatesUnit Tests
Integration Tests
Documentation
Does this PR require review from someone outside the core ubuntu-pro-client team?
|
@lucasmoura @orndorffgrant @dheyay I want to do this to ALL commands but please take preliminary looks to make sure you agree with the structure - easier to change earlier when less commands are implemented/affected |
4a10217
to
dfe6305
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 👏 👏 Excellent - big fan
How much should we convert to this at once? Should we just go for all of it? (each command in a separate commit, though)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, will make the CLI module readable 👀 🎈
(Should have just left this as a comment, since this is WIP)
@orndorffgrant I want to do this to all commands, yes - maybe incrementally, simple ones in this PR, if I find something more tricky (and I will) I can send it separate for ease of review. As it is a refactor anyway, we can merge without usability changes |
@renanrodrigo makes sense. Maybe can you prioritize the subcommands that have their own module? The we'd only have "new" commands in this form and "old" commands in |
Not sure - some of those have been separated exactly because they are more complicated somehow. I'll try and see what happens |
edd90dd
to
d127c36
Compare
Those classes will shape our CLI entrypoints with some OO so we write less boilerplate code and organize things better. Commands and options will be instances of those classes. Signed-off-by: Renan Rodrigo <[email protected]>
Signed-off-by: Renan Rodrigo <[email protected]>
we want to ensure long_name and help, but anything else just passes by. Signed-off-by: Renan Rodrigo <[email protected]>
Signed-off-by: Renan Rodrigo <[email protected]>
Signed-off-by: Renan Rodrigo <[email protected]>
Signed-off-by: Renan Rodrigo <[email protected]>
Signed-off-by: Renan Rodrigo <[email protected]>
Signed-off-by: Renan Rodrigo <[email protected]>
Grouping arguments enables us to create logical groups of arguments when dealing with help text in the future, and to create mutually exclusive groups - which are implemented in the code in one way or the other - and need to be standardized.
70477cf
to
c230f7a
Compare
@lucasmoura @orndorffgrant @dheyay this is now ready for review. Please keep in mind:
|
Signed-off-by: Renan Rodrigo <[email protected]>
Signed-off-by: Renan Rodrigo <[email protected]>
Signed-off-by: Renan Rodrigo <[email protected]>
Signed-off-by: Renan Rodrigo <[email protected]>
There is no need to create a whole new action for this using the new approach to the CLI. Furthermore, we already do some arg surgery, and this makes parse_args return immmeditely without further burden. And it does show the version. Signed-off-by: Renan Rodrigo <[email protected]>
Signed-off-by: Renan Rodrigo <[email protected]>
e74418e
to
61fbe4d
Compare
Signed-off-by: Renan Rodrigo <[email protected]>
Signed-off-by: Renan Rodrigo <[email protected]>
And the parser is now ProArgumentParser Signed-off-by: Renan Rodrigo <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving with the understanding that we need at least the most basic form of the follow up --help PR merged. Specifically, the usage line for sub-subcommands (e.g. pro config show
) is broken after this PR.
And a nit that doesn't block this PR: I'd like to change the help behave tests to test stdout equality rather than using a regexp. We can put "optional arguments" vs "options" into an example table variable per ubuntu release.
Why is this needed?
This PR solves all of our problems because this will set a new standard for the Pro Client CLI, which will be leveraged for the new UX implementation.
Test Steps
This PR should contain only refactors.Yep check tox and behave, small changes to help text