-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port to clio: Use simplified clio API (#63)
* use simplified clio API Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * caller creates root Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * [wip] Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * chore: update to latest clio Signed-off-by: Keith Zantow <kzantow@gmail.com> * chore: update to latest clio Signed-off-by: Keith Zantow <kzantow@gmail.com> * use the standard log redactor Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * bump clio to get logger redactor Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * dont allow for events that wont be published to attempt to redact Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * allow for lib consumers to set a redactor Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * account for lib consumers without needing to pass a redact store Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * dont allow for replacing the redact store Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Alex Goodman <alex.goodman@anchore.com> Signed-off-by: Keith Zantow <kzantow@gmail.com> Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> Co-authored-by: Keith Zantow <kzantow@gmail.com> Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
- Loading branch information
Showing
24 changed files
with
283 additions
and
287 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,11 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/anchore/clio" | ||
"github.com/anchore/quill/internal" | ||
) | ||
|
||
func Root(cfg *clio.Config, app clio.Application) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "", | ||
Version: app.Config().Version, | ||
} | ||
|
||
cmd.SetUsageTemplate(helpUsageTemplate) | ||
cmd.SetHelpTemplate(helpUsageTemplate) | ||
|
||
cmd.SetVersionTemplate(fmt.Sprintf("%s {{.Version}}\n", internal.ApplicationName)) | ||
|
||
return app.SetupPersistentCommand(cmd, cfg) | ||
func Root(app clio.Application) *cobra.Command { | ||
return app.SetupRootCommand(&cobra.Command{}) | ||
} | ||
|
||
var helpUsageTemplate = fmt.Sprintf(`{{if (or .Long .Short)}}{{.Long}}{{if not .Long}}{{.Short}}{{end}} | ||
{{end}}Usage:{{if (and .Runnable (ne .CommandPath "%s"))}} | ||
{{.UseLine}}{{end}}{{if .HasAvailableSubCommands}} | ||
{{.CommandPath}} [command]{{end}}{{if .HasExample}} | ||
{{.Example}}{{end}}{{if gt (len .Aliases) 0}} | ||
Aliases: | ||
{{.NameAndAliases}}{{end}}{{if .HasAvailableSubCommands}} | ||
Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}} | ||
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}} | ||
{{if not .CommandPath}}Global {{end}}Flags: | ||
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if (and .HasAvailableInheritedFlags (not .CommandPath))}} | ||
Global Flags: | ||
{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}} | ||
Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}} | ||
{{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}} | ||
Use "{{if .CommandPath}}{{.CommandPath}} {{end}}[command] --help" for more information about a command.{{end}} | ||
`, internal.ApplicationName) |
This file contains 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
This file contains 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
Oops, something went wrong.