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

chore: move flags to option package #1195

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

JeyJeyGao
Copy link
Contributor

@JeyJeyGao JeyJeyGao commented Feb 27, 2025

Moved internal/cmd/flags.go, internal/cmd/options.go and cmd/notation/common.go to option package to concentrate all the flags and options related code in one place.

Copy link

codecov bot commented Feb 27, 2025

Codecov Report

Attention: Patch coverage is 98.07692% with 1 line in your changes missing coverage. Please review.

Project coverage is 76.22%. Comparing base (1e5e342) to head (33e290e).

Files with missing lines Patch % Lines
cmd/notation/registry.go 80.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1195   +/-   ##
=======================================
  Coverage   76.22%   76.22%           
=======================================
  Files          71       70    -1     
  Lines        3634     3634           
=======================================
  Hits         2770     2770           
  Misses        668      668           
  Partials      196      196           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JeyJeyGao JeyJeyGao changed the title fix: move flags.go to option package fix: move flags to option package Feb 27, 2025
@JeyJeyGao JeyJeyGao changed the title fix: move flags to option package refactor: move flags to option package Feb 27, 2025
@JeyJeyGao JeyJeyGao marked this pull request as ready for review February 27, 2025 06:25
@JeyJeyGao JeyJeyGao changed the title refactor: move flags to option package chore: move flags to option package Feb 27, 2025
Signed-off-by: Junjie Gao <[email protected]>
@JeyJeyGao JeyJeyGao requested a review from shizhMSFT February 27, 2025 07:59
Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -12,7 +12,7 @@
// limitations under the License.

// Package cmd contains common flags and routines for all CLIs.
package cmd
package option
Copy link
Contributor

Choose a reason for hiding this comment

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

Well... After reading through the PR, I personally prefer the previous structure, where internal/cmd/flags.go is clear enough for any developer to add a new flag in it.

From description at line 14: // Package cmd contains common flags and routines for all CLIs.
This description on package option leaves a deep concern, and my question is: Why do we have to keep creating new PRs to just move around internal files, renaming the package names with something else, while reducing readability of the code base and increasing developer mistakes like above? Is this really a MUST to do item?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are two issues in the repo:

  1. Flags and options are located in multiple places: the internal/cmd package and cmd/notation/common.go.
  2. The internal/cmd package name is too broad. What does cmd mean? Everything we are working on is command-related.

The option package only includes flags and options that are used when defining a command opts struct, so I think this name is a better choice.

Copy link
Contributor

Choose a reason for hiding this comment

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

As I mentioned in the above comment, your description to package option is already wrong, I'm pretty sure this is a reduction of readability and increases developing difficulty for others.

If you really want this chore PR, my suggestion is:
Move flag related code from common.go to internal/cmd/flags.go and that's it.

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