Skip to content

Conversation

@folliehiyuki
Copy link

The main motivation of this PR is better support for shell completion. We won't need to maintain custom completion scripts, while having additional support for fish shell and powershell.

References:

to match the underlying cli.Exit() function it calls.

Signed-off-by: Hoang Nguyen <[email protected]>
@folliehiyuki
Copy link
Author

I noticed that urfave/cli v3 removed a hidden builtin feature to generate CLI documentation and put it into a separated Go package. Even though this is a bit out of scope for this PR, I added another commit to include a subcommand to generate man page for sops.

@folliehiyuki folliehiyuki changed the title Migrate urfave/cli to v3 Migrate urfave/cli to v3 + add manpage subcommand Oct 12, 2025
Copy link
Contributor

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

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

The last time I did investigated github.com/urfave/cli/v3 it was processing arguments sufficiently different that this would be a breaking change for the CLI interface of SOPS, since it parses some things quite differently, and thus not acceptable. Is there now some compatibility mode with v1? Or is this PR a breaking change?

Signed-off-by: Hoang Nguyen <[email protected]>
@folliehiyuki
Copy link
Author

folliehiyuki commented Oct 12, 2025

The last time I did investigated github.com/urfave/cli/v3 it was processing arguments sufficiently different

Can you explain the behavior? Here is some differences I spotted:

  • flags must be specified before arguments
  • there is no longer a concept of global flags. Flags can be passed through to subcommands by default

Apart from those, I don't see anything strange (yet). I only use a small subset of sops' functionalities, so I haven't tested every subcommand. Whether the above changes are breaking or not is up to you. Personally it doesn't affect my daily usage.

@folliehiyuki
Copy link
Author

folliehiyuki commented Oct 12, 2025

There are also differences in how --help flag and help subcommand are used (help subcommand can be invoked by another subcommand by default), as well as how the help text is displayed for root command and subcommands. If you desire the old help behavior, there are workarounds.

With this change, we don't need the Go template hack anymore. The help
text for subcommands displays correctly without showing global options.

Signed-off-by: Hoang Nguyen <[email protected]>
It's already defined as a root command flag.

Signed-off-by: Hoang Nguyen <[email protected]>
@folliehiyuki
Copy link
Author

Even with Local = true set for all global flags, they still don't behave the same as the current sops command (global flags can still be specified anywhere in the command line).

I opened urfave/cli#2208 as I don't know whether this is an intended behavior.

Sources: cli.EnvVars("SOPS_DECRYPTION_ORDER"),
},
}, keyserviceFlags...),
// Repeat keyserviceFlags, with Local value set to true
Copy link
Author

@folliehiyuki folliehiyuki Oct 13, 2025

Choose a reason for hiding this comment

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

I was tempted to inject Local = true into all global flags after they are defined, but the approach seems to be messy, and we probably will need to wrap the slice elements with a custom interface. Every global flag is defined plainly here, even with a level of duplication, for simplicity.

Ref: urfave/cli#2073

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.

2 participants