Skip to content

feat: Show contextual message on command usage exceptions#414

Merged
felangel merged 1 commit intomainfrom
renan/show-command-usage-on-error-2
May 31, 2022
Merged

feat: Show contextual message on command usage exceptions#414
felangel merged 1 commit intomainfrom
renan/show-command-usage-on-error-2

Conversation

@renancaraujo
Copy link
Contributor

Description

When a usage exception occurs inside a lead command, the CLI currently outputs the from the root command with description. This PR changes to show a more contextual error message:

Before:

$ very_good create --template xacalaca

"xacalaca" is not an allowed value for option "template".

🦄 A Very Good Command Line Interface

Usage: very_good <command> [arguments]

Global options:
-h, --help           Print this usage information.
    --version        Print the current version.
    --analytics      Toggle anonymous usage statistics.

          [false]    Disable anonymous usage statistics
          [true]     Enable anonymous usage statistics

Available commands:
  create     very_good create <output directory>
             Creates a new very good project in the specified directory.
  packages   Command for managing packages.
  test       Run tests in a Dart or Flutter project.

Run "very_good help <command>" for more information about a command.

Now:

$ very_good create --template xacalaca

"xacalaca" is not an allowed value for option "template".

Usage: very_good create <output directory>
-h, --help                    Print this usage information.
    --project-name            The project name for this new project. This must be a valid dart package name.
    --desc                    The description for this new project.
                              (defaults to "A Very Good Project created by Very Good CLI.")
    --org-name                The organization for this new project.
                              (defaults to "com.example.verygoodcore")
-t, --template                The template used to generate this new project.

          [core] (default)    Generate a Very Good Flutter application.
          [dart_pkg]          Generate a reusable Dart package.
          [flutter_pkg]       Generate a reusable Flutter package.
          [flutter_plugin]    Generate a reusable Flutter plugin.

    --android                 The plugin supports the Android platform.
                              (defaults to "true")
    --ios                     The plugin supports the iOS platform.
                              (defaults to "true")
    --web                     The plugin supports the Web platform.
                              (defaults to "true")
    --linux                   The plugin supports the Linux platform.
                              (defaults to "true")
    --macos                   The plugin supports the macOS platform.
                              (defaults to "true")
    --windows                 The plugin supports the Windows platform.
                              (defaults to "true")

Run "very_good help" to see global options.

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

@renancaraujo renancaraujo force-pushed the renan/show-command-usage-on-error-2 branch from 4cc6a90 to 25c9eb3 Compare May 30, 2022 15:00
@renancaraujo renancaraujo changed the title feat: Show command usage on command usage exceptions feat: Show contextual message on command usage exceptions May 30, 2022
@renancaraujo renancaraujo force-pushed the renan/show-command-usage-on-error-2 branch from 25c9eb3 to 378e449 Compare May 30, 2022 15:18
@renancaraujo renancaraujo marked this pull request as ready for review May 30, 2022 15:33
Copy link
Contributor

@wolfenrain wolfenrain left a comment

Choose a reason for hiding this comment

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

LGTM! That is so much cleaner!

Copy link
Contributor

@felangel felangel left a comment

Choose a reason for hiding this comment

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

💯

@felangel felangel merged commit 1523dcb into main May 31, 2022
@felangel felangel deleted the renan/show-command-usage-on-error-2 branch May 31, 2022 15:12
@felangel felangel mentioned this pull request May 31, 2022
7 tasks
ahsanf pushed a commit to Arkabyte-Teknologi/very_good_cli that referenced this pull request Aug 12, 2025
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.

3 participants