Refactor CLI to use urfave/cli v2#212
Merged
amitsaha merged 1 commit intoamitsaha:masterfrom Feb 27, 2026
Merged
Conversation
Replace flag.NewFlagSet + manual os.Args dispatch with a cli.App definition. This gives proper subcommand routing for init/validate, structured help output, and a clean foundation for future CLI expansion. - options.go: replace initConfig() with appFlags() + buildConfig(cCtx), using cCtx.IsSet() for config-file-then-CLI-flag precedence - main.go: define cli.App with Commands for init/validate and Action for the backup flow - config_file_test.go: add buildTestConfig() helper using urfave/cli - cli_test.go: read help from stdout (urfave/cli writes help to stdout) - Regenerate golden files for new help format
Owner
|
🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
flag.NewFlagSet+ manualos.Args[1]dispatch with aurfave/cli/v2cli.Appdefinitioninitandvalidatewith structured help outputcCtx.IsSet()as a direct replacement forfs.Visit()Test plan
go test ./...passes./gitbackup -hshows structured help with COMMANDS and GLOBAL OPTIONS sections./gitbackup init --helpand./gitbackup validate --helpshow subcommand help./gitbackup -config gitbackup.yml -backupdir /tmp/test./gitbackup -config gitbackup.yml -service github -backupdir /tmp/test-flagand--flag)