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

cli help text updates and flags cleanup #1564

Merged
merged 3 commits into from
Mar 1, 2023

Conversation

lkingland
Copy link
Member

@lkingland lkingland commented Feb 17, 2023

Changes

  • 🎁 verbose flag uses global setting throughout
  • 🧹 confirm flag added using shared visitor throughout
  • 🧹 path flag added using shared visitor throughout
  • 🧹 removes --version flag on root as redundant with subcommand
  • 🧹 splits main help's 'Main Commands' into 'Primary Commands' and 'Development Commands' groups
  • 🧹 Other general command structure cleanup

/kind cleanup

Notes

Refactor of root help text

In order to cohere more with kn, the root help text has been reworked to be
quite similar. Subcommands were not (yet) updated. Moving the lone
global flag, verbose, to subcommands assisted in this homogenization

Addition of the verbose flag directly to commands

The complexity added by having a single global (persistent) flag was not
worth the benefit of being able to elide defining it on each command.
Furthermore, when used as a plugin (to kn for example) it is easy to be
confused which set of global commands apply where. It's clearly simpler
to just addVerbose(cmd) right along with all the other flags.

Renaming setXFlag functions to addXFlag

setX usually implies that the object with context to the accessor will be
mutaed (user.setName("bob"), etc). Whereas addX resolves this ambiguity
by implying the passed argument will be mutated.

Removing the redundant --version flag

Both to be more coherent with kn, and because it seems to be the emergent
idiom for Go apps, the builtin --version flag was removed in favor of
the extant subcommand.

Ensuring --confirm and --path flags use accessor

As stated above, there is not enough flag-usage overlap between commands
to make global ("persistent") flags correct, but there are three which
are used enough to make a helper function useful: verbose, path and confirm.
These were added where missing throughout.

Creation of the Primary Commands and Development Commands groups

It is important to list the primary CRUD operations as the primary commands,
so that new users understand the high-level lifecycle of a function.
This creates that group, moving development/helper commands such as build,
run and invoke to their own group.

Release Note

Fixes issue where global settings for --verbose and --confirm were sometimes not considered
Removes the --version flag; please use the 'version' subcommand.

@knative-prow knative-prow bot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 17, 2023
- verbose flag uses global setting throughout
- confirm flag added using shared visitor throughout
- path flag added using shared visitor throughout
- removes --version flag on root as redundant with subcommand
- splits main help's 'Main Commands' into 'Primary Commands' and 'Development
  Commands' groups
- Moves RunE definition into flag struct literals
@codecov
Copy link

codecov bot commented Feb 17, 2023

Codecov Report

Base: 60.58% // Head: 60.61% // Increases project coverage by +0.03% 🎉

Coverage data is based on head (7649948) compared to base (9c5b5a8).
Patch coverage: 87.32% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1564      +/-   ##
==========================================
+ Coverage   60.58%   60.61%   +0.03%     
==========================================
  Files          75       76       +1     
  Lines       10340    10363      +23     
==========================================
+ Hits         6264     6282      +18     
+ Misses       3508     3502       -6     
- Partials      568      579      +11     
Flag Coverage Δ
integration-tests 51.04% <87.32%> (-0.28%) ⬇️
unit-tests-macos-latest 49.21% <87.32%> (?)
unit-tests-ubuntu-latest 50.69% <87.32%> (?)
unit-tests-windows-latest 49.08% <87.32%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
cmd/templates/templates.go 100.00% <ø> (ø)
cmd/config.go 30.00% <57.14%> (-0.19%) ⬇️
cmd/languages.go 86.04% <75.00%> (-3.12%) ⬇️
cmd/version.go 91.89% <75.00%> (-8.11%) ⬇️
cmd/run.go 70.63% <77.77%> (-1.73%) ⬇️
cmd/config_envs.go 26.56% <78.57%> (+0.76%) ⬆️
cmd/config_labels.go 72.89% <78.57%> (-0.41%) ⬇️
cmd/config_volumes.go 27.46% <78.57%> (+1.51%) ⬆️
cmd/list.go 64.35% <80.00%> (-5.37%) ⬇️
cmd/templates.go 80.57% <80.00%> (-1.78%) ⬇️
... and 28 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@lkingland lkingland marked this pull request as ready for review February 20, 2023 07:17
@knative-prow knative-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 20, 2023
@knative-prow knative-prow bot requested review from nainaz and rhuss February 20, 2023 07:17
@lkingland lkingland requested review from zroubalik, lance, matejvasek and salaboy and removed request for maximilien, rhuss, navidshaikh and nainaz February 20, 2023 07:17
@lkingland lkingland added this to the Release 1.10 milestone Feb 20, 2023
@lkingland lkingland changed the title cli help text and flags cleanup cli help text updates and flags cleanup Feb 20, 2023
@lkingland lkingland removed this from the Release 1.10 milestone Feb 20, 2023
Copy link
Contributor

@zroubalik zroubalik left a comment

Choose a reason for hiding this comment

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

/lgtm

Great job!

/hold for others

@knative-prow knative-prow bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 20, 2023
@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Feb 20, 2023
Copy link
Member

@lance lance left a comment

Choose a reason for hiding this comment

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

Looks great overall - nice clean up. I just have a small suggestion and one question about the version values.

cmd/root.go Outdated Show resolved Hide resolved
cmd/run.go Show resolved Hide resolved
@knative-prow knative-prow bot removed the lgtm Indicates that a PR is ready to be merged. label Feb 21, 2023
@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 24, 2023
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 28, 2023
Copy link
Contributor

@zroubalik zroubalik left a comment

Choose a reason for hiding this comment

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

/lgtm

Great improvement!

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Mar 1, 2023
@knative-prow
Copy link

knative-prow bot commented Mar 1, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lkingland, zroubalik

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [lkingland,zroubalik]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@zroubalik
Copy link
Contributor

/unhold

@knative-prow knative-prow bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 1, 2023
@knative-prow knative-prow bot merged commit aa582da into knative:main Mar 1, 2023
@lkingland lkingland deleted the cli-root-help branch March 5, 2023 22:32
@lkingland lkingland restored the cli-root-help branch March 6, 2023 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants