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

#396 Display the tools help output on 'ide help <tool>' #434

Merged
merged 8 commits into from
Jul 5, 2024

Conversation

slskiba
Copy link
Contributor

@slskiba slskiba commented Jul 1, 2024

Resolves #396.

While initially #396 sounded like a great idea, it might be troublesome in practice. Taking for example aws, aws help prints an incredibly long list of services (380+) to use with the aws cli, cluttering the output immensly.

I therefore suggest the following solution to this issue:

  • printToolHelp in ToolCommandlet runs the tool with the provided help command as input. The help command is by default set to null in ToolCommandlet, so if a tool does not specify otherwise, no tool-specific help is provided.
  • Tools that have a help output that is desirably for IDEasy-users, can specify the help command (e.g. Github CLI, see example output below). Most likely, this will be specified as -h, --help, or help for different tools.
  • Tools that have no or undesirable <tool> help output can override ToolCommandlet's printToolHelp (e.g. AWS CLI, instead of printing 400+ lines of usage help, we can advise the user to use aws help for detailed usage help)

Example output for ide help aws:

ide> help aws
__       ___ ___  ___
\ \     |_ _|   \| __|__ _ ____ _
 > >     | || |) | _|/ _` (_-< || |
/_/ ___ |___|___/|___\__,_/__/\_, |
   |___|                       |__/

Current version of IDE is SNAPSHOT
Usage: ide [option]* aws [<args>*]
Tool commandlet for AWS CLI.
The AWS Command Line Interface (AWS CLI) is an open source tool for managing AWS resources. Detailed documentation can be found at https://docs.aws.amazon.com/cli/

Values:
<args>  The commandline arguments to pass to the tool.
To get detailed help about the usage of the AWS CLI, use "aws help"

Options:
--locale        the locale (e.g. '--locale=de' for German language).
-b | --batch    enable batch mode (non-interactive).
-d | --debug    enable debug logging.
-f | --force    enable force mode.
-o | --offline  enable offline mode (skip updates or git pull, fail downloads or git clone).
-q | --quiet    disable info logging (only log success, warning or error).
-t | --trace    enable trace logging.

Example output for ide help gh:

ide> help gh
__       ___ ___  ___
\ \     |_ _|   \| __|__ _ ____ _
 > >     | || |) | _|/ _` (_-< || |
/_/ ___ |___|___/|___\__,_/__/\_, |
   |___|                       |__/

Current version of IDE is SNAPSHOT
Usage: ide [option]* gh [<args>*]
Tool commandlet for GitHub CLI.
GitHub CLI (Command Line Interface) allows to interact with GitHub repositories, issues, and pull requests from the command line. Detailed documentation can be found at https://cli.github.com/manual/

Values:
<args>  The commandline arguments to pass to the tool.

Work seamlessly with GitHub from the command line.

USAGE
  gh <command> <subcommand> [flags]

CORE COMMANDS
  auth:        Authenticate gh and git with GitHub
  browse:      Open the repository in the browser
  codespace:   Connect to and manage codespaces
  gist:        Manage gists
  issue:       Manage issues
  org:         Manage organizations
  pr:          Manage pull requests
  project:     Work with GitHub Projects.
  release:     Manage releases
  repo:        Manage repositories

GITHUB ACTIONS COMMANDS
  cache:       Manage GitHub Actions caches
  run:         View details about workflow runs
  workflow:    View details about GitHub Actions workflows

ALIAS COMMANDS
  co:          Alias for "pr checkout"

ADDITIONAL COMMANDS
  alias:       Create command shortcuts
  api:         Make an authenticated GitHub API request
  attestation: Work with artifact attestations
  completion:  Generate shell completion scripts
  config:      Manage configuration for gh
  extension:   Manage gh extensions
  gpg-key:     Manage GPG keys
  label:       Manage labels
  ruleset:     View info about repo rulesets
  search:      Search for repositories, issues, and pull requests
  secret:      Manage GitHub secrets
  ssh-key:     Manage SSH keys
  status:      Print information about relevant issues, pull requests, and notifications across repositories
  variable:    Manage GitHub Actions variables

HELP TOPICS
  actions:     Learn about working with GitHub Actions
  environment: Environment variables that can be used with gh
  exit-codes:  Exit codes used by gh
  formatting:  Formatting options for JSON data exported from gh
  mintty:      Information about using gh with MinTTY
  reference:   A comprehensive reference of all gh commands

FLAGS
  --help      Show help for command
  --version   Show gh version

EXAMPLES
  $ gh issue create
  $ gh repo clone cli/cli
  $ gh pr checkout 321

LEARN MORE
  Use `gh <command> <subcommand> --help` for more information about a command.
  Read the manual at https://cli.github.com/manual


Options:
--locale        the locale (e.g. '--locale=de' for German language).
-b | --batch    enable batch mode (non-interactive).
-d | --debug    enable debug logging.
-f | --force    enable force mode.
-o | --offline  enable offline mode (skip updates or git pull, fail downloads or git clone).
-q | --quiet    disable info logging (only log success, warning or error).
-t | --trace    enable trace logging.

@slskiba slskiba self-assigned this Jul 1, 2024
@coveralls
Copy link
Collaborator

coveralls commented Jul 1, 2024

Pull Request Test Coverage Report for Build 9743644633

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 11 unchanged lines in 5 files lost coverage.
  • Overall coverage decreased (-0.05%) to 60.283%

Files with Coverage Reduction New Missed Lines %
com/devonfw/tools/ide/tool/docker/Docker.java 1 4.76%
com/devonfw/tools/ide/tool/gh/Gh.java 1 66.67%
com/devonfw/tools/ide/tool/aws/Aws.java 2 5.71%
com/devonfw/tools/ide/commandlet/HelpCommandlet.java 2 93.37%
com/devonfw/tools/ide/tool/ToolCommandlet.java 5 69.93%
Totals Coverage Status
Change from base Build 9708861274: -0.05%
Covered Lines: 4994
Relevant Lines: 7974

💛 - Coveralls

@coveralls
Copy link
Collaborator

coveralls commented Jul 1, 2024

Pull Request Test Coverage Report for Build 9743646050

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 9 unchanged lines in 5 files lost coverage.
  • Overall coverage decreased (-0.03%) to 60.294%

Files with Coverage Reduction New Missed Lines %
com/devonfw/tools/ide/tool/docker/Docker.java 1 4.76%
com/devonfw/tools/ide/tool/gh/Gh.java 1 66.67%
com/devonfw/tools/ide/tool/aws/Aws.java 2 5.71%
com/devonfw/tools/ide/commandlet/HelpCommandlet.java 2 93.37%
com/devonfw/tools/ide/tool/ToolCommandlet.java 3 70.92%
Totals Coverage Status
Change from base Build 9708861274: -0.03%
Covered Lines: 4994
Relevant Lines: 7972

💛 - Coveralls

@slskiba slskiba changed the title #396 WIP: Display the tools help output on 'ide help <tool>' #396 Display the tools help output on 'ide help <tool>' Jul 2, 2024
@coveralls
Copy link
Collaborator

coveralls commented Jul 2, 2024

Pull Request Test Coverage Report for Build 9759176562

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 23 unchanged lines in 18 files lost coverage.
  • Overall coverage decreased (-0.02%) to 60.313%

Files with Coverage Reduction New Missed Lines %
com/devonfw/tools/ide/tool/terraform/Terraform.java 1 33.33%
com/devonfw/tools/ide/tool/helm/Helm.java 1 66.67%
com/devonfw/tools/ide/tool/docker/Docker.java 1 4.76%
com/devonfw/tools/ide/tool/gradle/Gradle.java 1 40.0%
com/devonfw/tools/ide/tool/gh/Gh.java 1 66.67%
com/devonfw/tools/ide/tool/dotnet/DotNet.java 1 66.67%
com/devonfw/tools/ide/tool/kotlinc/Kotlinc.java 1 66.67%
com/devonfw/tools/ide/tool/oc/Oc.java 1 66.67%
com/devonfw/tools/ide/tool/npm/Npm.java 1 95.65%
com/devonfw/tools/ide/tool/quarkus/Quarkus.java 1 66.67%
Totals Coverage Status
Change from base Build 9708861274: -0.02%
Covered Lines: 4996
Relevant Lines: 7981

💛 - Coveralls

@slskiba slskiba marked this pull request as ready for review July 2, 2024 10:24
Copy link
Contributor

@jan-vcapgemini jan-vcapgemini left a comment

Choose a reason for hiding this comment

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

Thanks for your additions. Looks good to me. Can be merged as soon as my small CR's are addressed.

@coveralls
Copy link
Collaborator

coveralls commented Jul 3, 2024

Pull Request Test Coverage Report for Build 9778567475

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 56 unchanged lines in 20 files lost coverage.
  • Overall coverage increased (+0.3%) to 60.643%

Files with Coverage Reduction New Missed Lines %
com/devonfw/tools/ide/tool/terraform/Terraform.java 1 33.33%
com/devonfw/tools/ide/tool/helm/Helm.java 1 66.67%
com/devonfw/tools/ide/tool/docker/Docker.java 1 4.76%
com/devonfw/tools/ide/tool/gradle/Gradle.java 1 40.0%
com/devonfw/tools/ide/tool/gh/Gh.java 1 66.67%
com/devonfw/tools/ide/tool/dotnet/DotNet.java 1 66.67%
com/devonfw/tools/ide/tool/kotlinc/Kotlinc.java 1 66.67%
com/devonfw/tools/ide/tool/oc/Oc.java 1 66.67%
com/devonfw/tools/ide/tool/npm/Npm.java 1 95.65%
com/devonfw/tools/ide/tool/quarkus/Quarkus.java 1 66.67%
Totals Coverage Status
Change from base Build 9708861274: 0.3%
Covered Lines: 5147
Relevant Lines: 8177

💛 - Coveralls

@jan-vcapgemini
Copy link
Contributor

If possible, please add a simple test to increase the test coverage here too. Just a check for a tool starting its simulated help command if it was found should suffice I guess.

Copy link
Member

@hohwille hohwille left a comment

Choose a reason for hiding this comment

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

@slskiba thanks for your PR. Well done - your solution looks good to me. 👍
I left a review comment for design improvement. Please have a look. Then we can merge.

@hohwille hohwille added help help/usage output CLI IDEasy command-line-interface (parsing args, etc.) labels Jul 5, 2024
@hohwille hohwille added this to the release:2024.07.001 milestone Jul 5, 2024
Copy link
Member

@hohwille hohwille left a comment

Choose a reason for hiding this comment

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

@slskiba thanks. Ready for merge now 👍

@coveralls
Copy link
Collaborator

coveralls commented Jul 5, 2024

Pull Request Test Coverage Report for Build 9808878877

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 68 unchanged lines in 19 files lost coverage.
  • Overall coverage decreased (-0.04%) to 61.755%

Files with Coverage Reduction New Missed Lines %
com/devonfw/tools/ide/tool/terraform/Terraform.java 1 33.33%
com/devonfw/tools/ide/tool/helm/Helm.java 1 66.67%
com/devonfw/tools/ide/tool/docker/Docker.java 1 4.76%
com/devonfw/tools/ide/tool/gradle/Gradle.java 1 80.0%
com/devonfw/tools/ide/tool/gh/Gh.java 1 66.67%
com/devonfw/tools/ide/tool/dotnet/DotNet.java 1 66.67%
com/devonfw/tools/ide/tool/kotlinc/Kotlinc.java 1 66.67%
com/devonfw/tools/ide/tool/oc/Oc.java 1 66.67%
com/devonfw/tools/ide/tool/npm/Npm.java 1 95.65%
com/devonfw/tools/ide/tool/quarkus/Quarkus.java 1 66.67%
Totals Coverage Status
Change from base Build 9808498015: -0.04%
Covered Lines: 5276
Relevant Lines: 8226

💛 - Coveralls

Copy link
Contributor

@jan-vcapgemini jan-vcapgemini left a comment

Choose a reason for hiding this comment

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

Looks good.

@hohwille hohwille merged commit 02b24d3 into devonfw:main Jul 5, 2024
4 checks passed
@jan-vcapgemini jan-vcapgemini added the reviewed Marks PRs that have been presented in the sprint-review meeting or that do not need to be presented. label Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI IDEasy command-line-interface (parsing args, etc.) help help/usage output reviewed Marks PRs that have been presented in the sprint-review meeting or that do not need to be presented.
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Display tool usage information when calling detailed help with 'ide help <tool>'
4 participants