Skip to content

chore(modular-cmds): flags helper, docs#700

Merged
ajaskolski merged 6 commits intomainfrom
introduce-shared-flags-modular-cmds
Feb 5, 2026
Merged

chore(modular-cmds): flags helper, docs#700
ajaskolski merged 6 commits intomainfrom
introduce-shared-flags-modular-cmds

Conversation

@ajaskolski
Copy link
Contributor

@ajaskolski ajaskolski commented Feb 3, 2026

@changeset-bot
Copy link

changeset-bot bot commented Feb 3, 2026

⚠️ No Changeset found

Latest commit: e35c4c9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ajaskolski ajaskolski force-pushed the introduce-shared-flags-modular-cmds branch from 1c130fd to 6231027 Compare February 3, 2026 13:04
@ajaskolski ajaskolski marked this pull request as ready for review February 3, 2026 13:34
@ajaskolski ajaskolski requested a review from a team as a code owner February 3, 2026 13:34
@ajaskolski ajaskolski requested review from Copilot and jkongie February 3, 2026 13:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a reusable flags helper package and enhances documentation for the state commands in the CLI framework. The changes support the CLD-1155 initiative by standardizing flag definitions and improving user-facing command documentation.

Changes:

  • Created a new flags package with helpers for common CLI flags (environment, print, output)
  • Updated state commands to use the new flags helpers with shorter flag names and deprecated aliases for backward compatibility
  • Enhanced command documentation with detailed descriptions and examples using the cli.LongDesc and cli.Examples utilities

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
engine/cld/commands/flags/flags.go New package with reusable flag helpers for environment, print, and output flags
engine/cld/commands/flags/flags_test.go Comprehensive tests for the new flags package
engine/cld/commands/state/generate.go Refactored to use flags helpers, added documentation, and introduced --print flag to control output behavior
engine/cld/commands/state/command.go Added validation method and documentation strings for the state command
engine/cld/commands/state/command_test.go Updated tests to verify new flag behavior and removed redundant tests
engine/cld/legacy/cli/commands/state_test.go Updated tests to reflect that environment flag is now local instead of persistent
engine/cld/commands/commands_test.go Updated tests to verify environment flag is local to subcommands

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ajaskolski ajaskolski force-pushed the introduce-shared-flags-modular-cmds branch from a655c4f to 737e480 Compare February 3, 2026 22:11
Copilot AI review requested due to automatic review settings February 4, 2026 08:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


// Set a timeout for the view operation as it may take a while
envdir := cfg.Domain.EnvDir(f.environment)
viewTimeout := 10 * time.Minute
Copy link
Collaborator

Choose a reason for hiding this comment

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

How does CCIP use this command if their state generation takes so long? Perhaps locally it's much faster and occurs in under 10 minutes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

really depends how many things you have onchain

Copy link
Collaborator

Choose a reason for hiding this comment

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

it could be ccip dont use the same context when in their logic.

)

// generateFlags holds all flags for the generate command.
type generateFlags struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@graham-chainlink What do you think of this convention?

Should we prefer GetX commands in the implementation, or use the persistent flags?

Copy link
Collaborator

@graham-chainlink graham-chainlink Feb 4, 2026

Choose a reason for hiding this comment

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

i kind of like it, by retrieving all the flag values in the newGenerateCmd function, and then pass in the generateFlags into runGenerate means that runGenerate does not need to know how to read the flag, easier testing and cleaner separation

Copy link
Collaborator

Choose a reason for hiding this comment

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

downside is if we have a lot of nested child commands , then we have to keep passing the flags down, but i dont think we have this problem here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The struct is fine. I was more referring to the intiialization of values in the fields.

I think it would be better to initialize the struct with

g := generateFlags{
    X: cmd.GetString("")
}

Note this is not exact code. I'm not sure of the exact methods

Copy link
Collaborator

Choose a reason for hiding this comment

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

i see, not strong opinion, i like the pointer approach eg StringVarP, in this case, it requires less line of code as we declared and set value of the flag in the same line, so we dont have to explicitly retrieve it again.

@ajaskolski ajaskolski force-pushed the introduce-shared-flags-modular-cmds branch from 83cec5f to d1bb809 Compare February 4, 2026 08:51
Copilot AI review requested due to automatic review settings February 4, 2026 08:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if err != nil {
return fmt.Errorf("failed to load environment: %w", err)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in the orignal previousState flag was never used actually in the code so providing it just did nothing, added the logic for it but we may also just delete it if not used

Copilot AI review requested due to automatic review settings February 4, 2026 09:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ajaskolski
Copy link
Contributor Author

I finished with batch updates, if you will have moment please revisit the PR.

@ajaskolski ajaskolski force-pushed the introduce-shared-flags-modular-cmds branch from e67ca0a to e35c4c9 Compare February 5, 2026 07:10
@cl-sonarqube-production
Copy link

@ajaskolski ajaskolski added this pull request to the merge queue Feb 5, 2026
Merged via the queue into main with commit 18ed7ae Feb 5, 2026
20 checks passed
@ajaskolski ajaskolski deleted the introduce-shared-flags-modular-cmds branch February 5, 2026 08:01
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