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

Refactor CLI to remove --severity from some commands #1700

Merged
merged 1 commit into from
Mar 31, 2023

Conversation

mtdowling
Copy link
Member

@mtdowling mtdowling commented Mar 31, 2023

Some commands don't need the severity option and should instead only show validation events if the command fails. This includes the ast and select commands. Neither command should allow a custom severity, and they should only show validation events when the model can't be loaded (i.e., DANGER or ERROR events). To make this work, I refactored several CLI classes:

  • Add a shared ModeBuilder abstraction to cleanup the old utility code. This class now uses a Validator.Mode to indicate how validation is reported, decoupling arguments from the shared validation abstraction.
  • Move --discover and --discover-classpath to DiscoveryOptions
  • Move --severity to SeverityOption so it's more granular
  • Add the ability to check for receivers on Arguments
  • Add the ability to remove receivers from Arguments
  • Add the ability to get positional arguments more than once
  • Can now add/remove argument receivers in ClasspathCommand subclasses

This makes the current state of arguments:

Usage: smithy validate [--help | -h]
                       [--debug] [--quiet]
                       [--no-color] [--force-color]
                       [--stacktrace] [--logging LOG_LEVEL]
                       [--config | -c CONFIG_PATH...]
                       [--no-config] [--severity SEVERITY]
                       [--allow-unknown-traits]
                       [--output OUTPUT_PATH] [<MODELS>]

Usage: smithy build [--help | -h]
                    [--debug] [--quiet] [--no-color]
                    [--force-color] [--stacktrace]
                    [--logging LOG_LEVEL]
                    [--config | -c CONFIG_PATH...]
                    [--no-config] [--severity SEVERITY]
                    [--allow-unknown-traits]
                    [--output OUTPUT_PATH]
                    [--projection PROJECTION_NAME]
                    [--plugin PLUGIN_NAME] [<MODELS>]

Usage: smithy diff [--help | -h] [--debug]
                   [--quiet] [--no-color]
                   [--force-color] [--stacktrace]
                   [--logging LOG_LEVEL]
                   [--config | -c CONFIG_PATH...]
                   [--no-config] [--severity SEVERITY]
                   [--allow-unknown-traits]
                   [--output OUTPUT_PATH]
                   [--old OLD_MODELS...] [--new NEW_MODELS...]
                   [<MODELS>]

Usage: smithy ast [--help | -h] [--debug]
                  [--quiet] [--no-color]
                  [--force-color] [--stacktrace]
                  [--logging LOG_LEVEL]
                  [--config | -c CONFIG_PATH...]
                  [--no-config] [--allow-unknown-traits]
                  [--output OUTPUT_PATH] [<MODELS>]

Usage: smithy clean [--help | -h]
                    [--debug] [--quiet] [--no-color]
                    [--force-color] [--stacktrace]
                    [--logging LOG_LEVEL]
                    [--config | -c CONFIG_PATH...]
                    [--no-config]

Usage: smithy upgrade-1-to-2 [--help | -h]
                             [--debug] [--quiet]
                             [--no-color] [--force-color]
                             [--stacktrace]
                             [--logging LOG_LEVEL]
                             [--config | -c CONFIG_PATH...]
                             [--no-config]
                             [--allow-unknown-traits]
                             [--output OUTPUT_PATH] [<MODELS>]

Usage: smithy select [--help | -h]
                     [--debug] [--quiet] [--no-color]
                     [--force-color] [--stacktrace]
                     [--logging LOG_LEVEL]
                     [--config | -c CONFIG_PATH...]
                     [--no-config] [--allow-unknown-traits]
                     [--output OUTPUT_PATH]
                     [--selector SELECTOR]
                     [--show-traits TRAITS] [--vars]
                     [<MODELS>]

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Some commands don't need the severity option and should instead only show
validation events if the command fails. This includes the ast and select
commands. To make this work, I refactored several CLI classes:

* Add a shared ModeBuilder abstraction to cleanup the old utility code. This
  class now uses a Validator.Mode to indicate how validation is reported,
  decoupling arguments from the shared validation abstraction.
* Move --discover and --discover-classpath to DiscoveryOptions
* Move --severity to SeverityOption so it's more granular
* Add the ability to check for receivers on Arguments
* Add the ability to remove receivers from Arguments
* Add the ability to get positional arguments more than once
* Can now add/remove argument receivers in ClasspathCommand subclasses
@mtdowling mtdowling requested a review from a team as a code owner March 31, 2023 03:18
@mtdowling mtdowling merged commit 5c16a9a into main Mar 31, 2023
@mtdowling mtdowling deleted the remove-severity-from-some-commands branch April 7, 2023 03:30
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