From 57e7572b6f64aa6904a6c5dd731e6899b5c27f68 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sat, 30 Nov 2024 15:23:44 +0100 Subject: [PATCH] Unify cli commands and flags (#4481) - Unify command and flag descriptions - Unify logs - Rename `woodpecker-cli [registry|ssecret|...] info` commands to `woodpecker-cli [registry|ssecret|...] show` --- cli/admin/loglevel/loglevel.go | 4 ++-- cli/admin/registry/registry.go | 2 +- cli/admin/registry/registry_add.go | 2 +- .../{registry_info.go => registry_show.go} | 10 +++++----- cli/admin/secret/secret.go | 2 +- cli/admin/secret/secret_add.go | 2 +- .../secret/{secret_info.go => secret_show.go} | 10 +++++----- cli/admin/user/user.go | 2 +- cli/admin/user/user_add.go | 2 +- cli/admin/user/{user_info.go => user_show.go} | 10 +++++----- cli/common/hooks.go | 10 +++++----- cli/internal/config/config.go | 16 ++++++++-------- cli/lint/lint.go | 4 ++-- cli/org/registry/registry.go | 2 +- cli/org/registry/registry_add.go | 2 +- .../{registry_info.go => registry_show.go} | 10 +++++----- cli/org/secret/secret.go | 2 +- cli/org/secret/secret_add.go | 2 +- cli/org/secret/secret_set.go | 4 ++-- .../secret/{secret_info.go => secret_show.go} | 10 +++++----- cli/pipeline/deploy/deploy.go | 2 +- cli/pipeline/last.go | 2 +- cli/pipeline/list.go | 4 ++-- cli/pipeline/pipeline.go | 2 +- cli/pipeline/{info.go => show.go} | 10 +++++----- cli/pipeline/start.go | 2 +- cli/repo/cron/cron.go | 2 +- cli/repo/cron/{cron_info.go => cron_show.go} | 10 +++++----- cli/repo/registry/registry.go | 2 +- cli/repo/registry/registry_add.go | 2 +- .../{registry_info.go => registry_show.go} | 10 +++++----- cli/repo/repo.go | 2 +- cli/repo/{repo_info.go => repo_show.go} | 10 +++++----- cli/repo/repo_update.go | 4 ++-- cli/repo/secret/secret.go | 2 +- cli/repo/secret/secret_add.go | 6 +++--- cli/repo/secret/secret_set.go | 4 ++-- .../secret/{secret_info.go => secret_show.go} | 10 +++++----- cli/setup/setup.go | 8 ++++---- cli/setup/token_fetcher.go | 8 ++++---- cli/update/command.go | 10 +++++----- cli/update/updater.go | 16 ++++++++-------- docs/src/pages/migrations.md | 1 + 43 files changed, 119 insertions(+), 118 deletions(-) rename cli/admin/registry/{registry_info.go => registry_show.go} (88%) rename cli/admin/secret/{secret_info.go => secret_show.go} (88%) rename cli/admin/user/{user_info.go => user_show.go} (88%) rename cli/org/registry/{registry_info.go => registry_show.go} (88%) rename cli/org/secret/{secret_info.go => secret_show.go} (89%) rename cli/pipeline/{info.go => show.go} (90%) rename cli/repo/cron/{cron_info.go => cron_show.go} (89%) rename cli/repo/registry/{registry_info.go => registry_show.go} (88%) rename cli/repo/{repo_info.go => repo_show.go} (90%) rename cli/repo/secret/{secret_info.go => secret_show.go} (89%) diff --git a/cli/admin/loglevel/loglevel.go b/cli/admin/loglevel/loglevel.go index 947e99eaf23..323974d0125 100644 --- a/cli/admin/loglevel/loglevel.go +++ b/cli/admin/loglevel/loglevel.go @@ -29,7 +29,7 @@ import ( var Command = &cli.Command{ Name: "log-level", ArgsUsage: "[level]", - Usage: "get the logging level of the server, or set it with [level]", + Usage: "retrieve log level from server, or set it with [level]", Action: logLevel, } @@ -59,6 +59,6 @@ func logLevel(ctx context.Context, c *cli.Command) error { } } - log.Info().Msgf("logging level: %s", ll.Level) + log.Info().Msgf("log level: %s", ll.Level) return nil } diff --git a/cli/admin/registry/registry.go b/cli/admin/registry/registry.go index 3d9c4de500e..1717803c6fc 100644 --- a/cli/admin/registry/registry.go +++ b/cli/admin/registry/registry.go @@ -26,7 +26,7 @@ var Command = &cli.Command{ registryCreateCmd, registryDeleteCmd, registryUpdateCmd, - registryInfoCmd, + registryShowCmd, registryListCmd, }, } diff --git a/cli/admin/registry/registry_add.go b/cli/admin/registry/registry_add.go index a378a8a2f68..b09f8a74ec2 100644 --- a/cli/admin/registry/registry_add.go +++ b/cli/admin/registry/registry_add.go @@ -27,7 +27,7 @@ import ( var registryCreateCmd = &cli.Command{ Name: "add", - Usage: "adds a registry", + Usage: "add a registry", Action: registryCreate, Flags: []cli.Flag{ &cli.StringFlag{ diff --git a/cli/admin/registry/registry_info.go b/cli/admin/registry/registry_show.go similarity index 88% rename from cli/admin/registry/registry_info.go rename to cli/admin/registry/registry_show.go index 80b78546f5f..c7ae1359dd7 100644 --- a/cli/admin/registry/registry_info.go +++ b/cli/admin/registry/registry_show.go @@ -25,10 +25,10 @@ import ( "go.woodpecker-ci.org/woodpecker/v2/cli/internal" ) -var registryInfoCmd = &cli.Command{ - Name: "info", - Usage: "display registry info", - Action: registryInfo, +var registryShowCmd = &cli.Command{ + Name: "show", + Usage: "show registry information", + Action: registryShow, Flags: []cli.Flag{ &cli.StringFlag{ Name: "hostname", @@ -39,7 +39,7 @@ var registryInfoCmd = &cli.Command{ }, } -func registryInfo(ctx context.Context, c *cli.Command) error { +func registryShow(ctx context.Context, c *cli.Command) error { var ( hostname = c.String("hostname") format = c.String("format") + "\n" diff --git a/cli/admin/secret/secret.go b/cli/admin/secret/secret.go index ffd466f9472..b3496b076a2 100644 --- a/cli/admin/secret/secret.go +++ b/cli/admin/secret/secret.go @@ -26,7 +26,7 @@ var Command = &cli.Command{ secretCreateCmd, secretDeleteCmd, secretUpdateCmd, - secretInfoCmd, + secretShowCmd, secretListCmd, }, } diff --git a/cli/admin/secret/secret_add.go b/cli/admin/secret/secret_add.go index f2cf88c8c7e..07afa813477 100644 --- a/cli/admin/secret/secret_add.go +++ b/cli/admin/secret/secret_add.go @@ -27,7 +27,7 @@ import ( var secretCreateCmd = &cli.Command{ Name: "add", - Usage: "adds a secret", + Usage: "add a secret", ArgsUsage: "[repo-id|repo-full-name]", Action: secretCreate, Flags: []cli.Flag{ diff --git a/cli/admin/secret/secret_info.go b/cli/admin/secret/secret_show.go similarity index 88% rename from cli/admin/secret/secret_info.go rename to cli/admin/secret/secret_show.go index 7efdacc25bd..09ce610b89b 100644 --- a/cli/admin/secret/secret_info.go +++ b/cli/admin/secret/secret_show.go @@ -26,11 +26,11 @@ import ( "go.woodpecker-ci.org/woodpecker/v2/cli/internal" ) -var secretInfoCmd = &cli.Command{ - Name: "info", - Usage: "display secret info", +var secretShowCmd = &cli.Command{ + Name: "show", + Usage: "show secret information", ArgsUsage: "[repo-id|repo-full-name]", - Action: secretInfo, + Action: secretShow, Flags: []cli.Flag{ &cli.StringFlag{ Name: "name", @@ -40,7 +40,7 @@ var secretInfoCmd = &cli.Command{ }, } -func secretInfo(ctx context.Context, c *cli.Command) error { +func secretShow(ctx context.Context, c *cli.Command) error { var ( secretName = c.String("name") format = c.String("format") + "\n" diff --git a/cli/admin/user/user.go b/cli/admin/user/user.go index 78b552b3665..fe68e5d4760 100644 --- a/cli/admin/user/user.go +++ b/cli/admin/user/user.go @@ -24,7 +24,7 @@ var Command = &cli.Command{ Usage: "manage users", Commands: []*cli.Command{ userListCmd, - userInfoCmd, + userShowCmd, userAddCmd, userRemoveCmd, }, diff --git a/cli/admin/user/user_add.go b/cli/admin/user/user_add.go index 80012158e4b..b05b5f6a92f 100644 --- a/cli/admin/user/user_add.go +++ b/cli/admin/user/user_add.go @@ -26,7 +26,7 @@ import ( var userAddCmd = &cli.Command{ Name: "add", - Usage: "adds a user", + Usage: "add a user", ArgsUsage: "", Action: userAdd, } diff --git a/cli/admin/user/user_info.go b/cli/admin/user/user_show.go similarity index 88% rename from cli/admin/user/user_info.go rename to cli/admin/user/user_show.go index bfebed93fd4..6ed453fc8c3 100644 --- a/cli/admin/user/user_info.go +++ b/cli/admin/user/user_show.go @@ -26,15 +26,15 @@ import ( "go.woodpecker-ci.org/woodpecker/v2/cli/internal" ) -var userInfoCmd = &cli.Command{ - Name: "info", - Usage: "show user details", +var userShowCmd = &cli.Command{ + Name: "show", + Usage: "show user information", ArgsUsage: "", - Action: userInfo, + Action: userShow, Flags: []cli.Flag{common.FormatFlag(tmplUserInfo)}, } -func userInfo(ctx context.Context, c *cli.Command) error { +func userShow(ctx context.Context, c *cli.Command) error { client, err := internal.NewClient(ctx, c) if err != nil { return err diff --git a/cli/common/hooks.go b/cli/common/hooks.go index 9ff74d1ad3d..d35dd2fd675 100644 --- a/cli/common/hooks.go +++ b/cli/common/hooks.go @@ -35,18 +35,18 @@ func Before(ctx context.Context, c *cli.Command) (context.Context, error) { waitForUpdateCheck, cancelWaitForUpdate = context.WithCancelCause(context.Background()) defer cancelWaitForUpdate(errors.New("update check finished")) - log.Debug().Msg("Checking for updates ...") + log.Debug().Msg("checking for updates ...") newVersion, err := update.CheckForUpdate(waitForUpdateCheck, false) //nolint:contextcheck if err != nil { - log.Error().Err(err).Msgf("Failed to check for updates") + log.Error().Err(err).Msgf("failed to check for updates") return } if newVersion != nil { - log.Warn().Msgf("A new version of woodpecker-cli is available: %s. Update by running: %s update", newVersion.Version, c.Root().Name) + log.Warn().Msgf("new version of woodpecker-cli is available: %s, update with: %s update", newVersion.Version, c.Root().Name) } else { - log.Debug().Msgf("No update required") + log.Debug().Msgf("no update required") } }(ctx) @@ -59,7 +59,7 @@ func After(_ context.Context, _ *cli.Command) error { case <-waitForUpdateCheck.Done(): // When the actual command already finished, we still wait 500ms for the update check to finish case <-time.After(time.Millisecond * 500): - log.Debug().Msg("Update check stopped due to timeout") + log.Debug().Msg("update check stopped due to timeout") cancelWaitForUpdate(errors.New("update check timeout")) } } diff --git a/cli/internal/config/config.go b/cli/internal/config/config.go index 817a859c380..274572c6790 100644 --- a/cli/internal/config/config.go +++ b/cli/internal/config/config.go @@ -44,7 +44,7 @@ func Load(ctx context.Context, c *cli.Command) error { } if config.ServerURL == "" || config.Token == "" { - log.Info().Msg("The woodpecker-cli is not yet set up. Please run `woodpecker-cli setup` or provide the required environment variables / flags.") + log.Info().Msg("woodpecker-cli is not set up, run `woodpecker-cli setup` or provide required environment variables/flags") return errors.New("woodpecker-cli is not configured") } @@ -63,7 +63,7 @@ func Load(ctx context.Context, c *cli.Command) error { return err } - log.Debug().Any("config", config).Msg("Loaded config") + log.Debug().Any("config", config).Msg("loaded config") return nil } @@ -93,16 +93,16 @@ func Get(_ context.Context, c *cli.Command, _configPath string) (*Config, error) return nil, err } - log.Debug().Str("configPath", configPath).Msg("Checking for config file") + log.Debug().Str("configPath", configPath).Msg("checking for config file") content, err := os.ReadFile(configPath) switch { case err != nil && !os.IsNotExist(err): - log.Debug().Err(err).Msg("Failed to read the config file") + log.Debug().Err(err).Msg("failed to read the config file") return nil, err case err != nil && os.IsNotExist(err): - log.Debug().Msg("The config file does not exist") + log.Debug().Msg("config file does not exist") default: configFromFile := &Config{} @@ -111,7 +111,7 @@ func Get(_ context.Context, c *cli.Command, _configPath string) (*Config, error) return nil, err } conf.MergeIfNotSet(configFromFile) - log.Debug().Msg("Loaded config from file") + log.Debug().Msg("loaded config from file") } // if server or token are explicitly set, use them @@ -123,11 +123,11 @@ func Get(_ context.Context, c *cli.Command, _configPath string) (*Config, error) service := c.Root().Name secret, err := keyring.Get(service, conf.ServerURL) if errors.Is(err, keyring.ErrUnsupportedPlatform) { - log.Warn().Msg("Keyring is not supported on this platform") + log.Warn().Msg("keyring is not supported on this platform") return conf, nil } if errors.Is(err, keyring.ErrNotFound) { - log.Warn().Msg("Token not found in keyring") + log.Warn().Msg("token not found in keyring") return conf, nil } conf.Token = secret diff --git a/cli/lint/lint.go b/cli/lint/lint.go index 3872ef09304..b52175daa09 100644 --- a/cli/lint/lint.go +++ b/cli/lint/lint.go @@ -40,12 +40,12 @@ var Command = &cli.Command{ &cli.StringSliceFlag{ Sources: cli.EnvVars("WOODPECKER_PLUGINS_PRIVILEGED"), Name: "plugins-privileged", - Usage: "Allow plugins to run in privileged mode, if environment variable is defined but empty there will be none", + Usage: "allow plugins to run in privileged mode, if set empty, there is no", }, &cli.StringSliceFlag{ Sources: cli.EnvVars("WOODPECKER_PLUGINS_TRUSTED_CLONE"), Name: "plugins-trusted-clone", - Usage: "Plugins which are trusted to handle Git credentials in clone steps", + Usage: "plugins that are trusted to handle Git credentials in cloning steps", Value: constant.TrustedClonePlugins, }, &cli.BoolFlag{ diff --git a/cli/org/registry/registry.go b/cli/org/registry/registry.go index aa4f9f23ba8..ed8051bd9f2 100644 --- a/cli/org/registry/registry.go +++ b/cli/org/registry/registry.go @@ -30,7 +30,7 @@ var Command = &cli.Command{ registryCreateCmd, registryDeleteCmd, registryUpdateCmd, - registryInfoCmd, + registryShowCmd, registryListCmd, }, } diff --git a/cli/org/registry/registry_add.go b/cli/org/registry/registry_add.go index d82859f00b6..e6b184bcf05 100644 --- a/cli/org/registry/registry_add.go +++ b/cli/org/registry/registry_add.go @@ -28,7 +28,7 @@ import ( var registryCreateCmd = &cli.Command{ Name: "add", - Usage: "adds a registry", + Usage: "add a registry", ArgsUsage: "[org-id|org-full-name]", Action: registryCreate, Flags: []cli.Flag{ diff --git a/cli/org/registry/registry_info.go b/cli/org/registry/registry_show.go similarity index 88% rename from cli/org/registry/registry_info.go rename to cli/org/registry/registry_show.go index 752c54c1893..8fd7a77f096 100644 --- a/cli/org/registry/registry_info.go +++ b/cli/org/registry/registry_show.go @@ -25,11 +25,11 @@ import ( "go.woodpecker-ci.org/woodpecker/v2/cli/internal" ) -var registryInfoCmd = &cli.Command{ - Name: "info", - Usage: "display registry info", +var registryShowCmd = &cli.Command{ + Name: "show", + Usage: "show registry information", ArgsUsage: "[org-id|org-full-name]", - Action: registryInfo, + Action: registryShow, Flags: []cli.Flag{ common.OrgFlag, &cli.StringFlag{ @@ -41,7 +41,7 @@ var registryInfoCmd = &cli.Command{ }, } -func registryInfo(ctx context.Context, c *cli.Command) error { +func registryShow(ctx context.Context, c *cli.Command) error { var ( hostname = c.String("hostname") format = c.String("format") + "\n" diff --git a/cli/org/secret/secret.go b/cli/org/secret/secret.go index 11206be538b..21579993b8d 100644 --- a/cli/org/secret/secret.go +++ b/cli/org/secret/secret.go @@ -30,7 +30,7 @@ var Command = &cli.Command{ secretCreateCmd, secretDeleteCmd, secretUpdateCmd, - secretInfoCmd, + secretShowCmd, secretListCmd, }, } diff --git a/cli/org/secret/secret_add.go b/cli/org/secret/secret_add.go index 97b901cddce..d356773f1e9 100644 --- a/cli/org/secret/secret_add.go +++ b/cli/org/secret/secret_add.go @@ -28,7 +28,7 @@ import ( var secretCreateCmd = &cli.Command{ Name: "add", - Usage: "adds a secret", + Usage: "add a secret", ArgsUsage: "[repo-id|repo-full-name]", Action: secretCreate, Flags: []cli.Flag{ diff --git a/cli/org/secret/secret_set.go b/cli/org/secret/secret_set.go index 2e25655aa4c..4357d3296fb 100644 --- a/cli/org/secret/secret_set.go +++ b/cli/org/secret/secret_set.go @@ -43,11 +43,11 @@ var secretUpdateCmd = &cli.Command{ }, &cli.StringSliceFlag{ Name: "event", - Usage: "secret limited to these events", + Usage: "limit secret to these event", }, &cli.StringSliceFlag{ Name: "image", - Usage: "secret limited to these images", + Usage: "limit secret to these image", }, }, } diff --git a/cli/org/secret/secret_info.go b/cli/org/secret/secret_show.go similarity index 89% rename from cli/org/secret/secret_info.go rename to cli/org/secret/secret_show.go index 8025a977f79..9a78741c21c 100644 --- a/cli/org/secret/secret_info.go +++ b/cli/org/secret/secret_show.go @@ -26,11 +26,11 @@ import ( "go.woodpecker-ci.org/woodpecker/v2/cli/internal" ) -var secretInfoCmd = &cli.Command{ - Name: "info", - Usage: "display secret info", +var secretShowCmd = &cli.Command{ + Name: "show", + Usage: "show secret information", ArgsUsage: "[repo-id|repo-full-name]", - Action: secretInfo, + Action: secretShow, Flags: []cli.Flag{ common.OrgFlag, &cli.StringFlag{ @@ -41,7 +41,7 @@ var secretInfoCmd = &cli.Command{ }, } -func secretInfo(ctx context.Context, c *cli.Command) error { +func secretShow(ctx context.Context, c *cli.Command) error { var ( secretName = c.String("name") format = c.String("format") + "\n" diff --git a/cli/pipeline/deploy/deploy.go b/cli/pipeline/deploy/deploy.go index 8a742fc8a4a..199310ac68a 100644 --- a/cli/pipeline/deploy/deploy.go +++ b/cli/pipeline/deploy/deploy.go @@ -53,7 +53,7 @@ var Command = &cli.Command{ &cli.StringSliceFlag{ Name: "param", Aliases: []string{"p"}, - Usage: "custom parameters to be injected into the step environment. Format: KEY=value", + Usage: "custom parameters to inject into the step environment. Format: KEY=value", }, }, } diff --git a/cli/pipeline/last.go b/cli/pipeline/last.go index 131c20902d7..49f1611427f 100644 --- a/cli/pipeline/last.go +++ b/cli/pipeline/last.go @@ -26,7 +26,7 @@ import ( var pipelineLastCmd = &cli.Command{ Name: "last", - Usage: "show latest pipeline details", + Usage: "show latest pipeline information", ArgsUsage: "", Action: pipelineLast, Flags: append(common.OutputFlags("table"), []cli.Flag{ diff --git a/cli/pipeline/list.go b/cli/pipeline/list.go index bfd24981b67..afe1f380317 100644 --- a/cli/pipeline/list.go +++ b/cli/pipeline/list.go @@ -52,7 +52,7 @@ func buildPipelineListCmd() *cli.Command { }, &cli.TimestampFlag{ Name: "before", - Usage: "only return pipelines before this RFC3339 date", + Usage: "only return pipelines before this date (RFC3339)", Config: cli.TimestampConfig{ Layouts: []string{ time.RFC3339, @@ -61,7 +61,7 @@ func buildPipelineListCmd() *cli.Command { }, &cli.TimestampFlag{ Name: "after", - Usage: "only return pipelines after this RFC3339 date", + Usage: "only return pipelines after this date (RFC3339)", Config: cli.TimestampConfig{ Layouts: []string{ time.RFC3339, diff --git a/cli/pipeline/pipeline.go b/cli/pipeline/pipeline.go index 866158e88ac..454e7064daf 100644 --- a/cli/pipeline/pipeline.go +++ b/cli/pipeline/pipeline.go @@ -35,7 +35,7 @@ var Command = &cli.Command{ Commands: []*cli.Command{ buildPipelineListCmd(), pipelineLastCmd, - pipelineInfoCmd, + pipelineShowCmd, pipelineStopCmd, pipelineStartCmd, pipelineApproveCmd, diff --git a/cli/pipeline/info.go b/cli/pipeline/show.go similarity index 90% rename from cli/pipeline/info.go rename to cli/pipeline/show.go index 27d05a24458..165c6a70a62 100644 --- a/cli/pipeline/info.go +++ b/cli/pipeline/show.go @@ -25,15 +25,15 @@ import ( "go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker" ) -var pipelineInfoCmd = &cli.Command{ - Name: "info", - Usage: "show pipeline details", +var pipelineShowCmd = &cli.Command{ + Name: "show", + Usage: "show pipeline information", ArgsUsage: " [pipeline]", - Action: pipelineInfo, + Action: pipelineShow, Flags: common.OutputFlags("table"), } -func pipelineInfo(ctx context.Context, c *cli.Command) error { +func pipelineShow(ctx context.Context, c *cli.Command) error { repoIDOrFullName := c.Args().First() client, err := internal.NewClient(ctx, c) if err != nil { diff --git a/cli/pipeline/start.go b/cli/pipeline/start.go index 4a9b380a237..02c3e3de039 100644 --- a/cli/pipeline/start.go +++ b/cli/pipeline/start.go @@ -35,7 +35,7 @@ var pipelineStartCmd = &cli.Command{ &cli.StringSliceFlag{ Name: "param", Aliases: []string{"p"}, - Usage: "custom parameters to be injected into the step environment. Format: KEY=value", + Usage: "custom parameters to inject into the step environment. Format: KEY=value", }, }, } diff --git a/cli/repo/cron/cron.go b/cli/repo/cron/cron.go index efcfa2c17e7..364813876f7 100644 --- a/cli/repo/cron/cron.go +++ b/cli/repo/cron/cron.go @@ -26,7 +26,7 @@ var Command = &cli.Command{ cronCreateCmd, cronDeleteCmd, cronUpdateCmd, - cronInfoCmd, + cronShowCmd, cronListCmd, }, } diff --git a/cli/repo/cron/cron_info.go b/cli/repo/cron/cron_show.go similarity index 89% rename from cli/repo/cron/cron_info.go rename to cli/repo/cron/cron_show.go index 276ed15a91e..2e8b86650b3 100644 --- a/cli/repo/cron/cron_info.go +++ b/cli/repo/cron/cron_show.go @@ -25,11 +25,11 @@ import ( "go.woodpecker-ci.org/woodpecker/v2/cli/internal" ) -var cronInfoCmd = &cli.Command{ - Name: "info", - Usage: "display info about a cron job", +var cronShowCmd = &cli.Command{ + Name: "show", + Usage: "show cron job information", ArgsUsage: "[repo-id|repo-full-name]", - Action: cronInfo, + Action: cronShow, Flags: []cli.Flag{ common.RepoFlag, &cli.StringFlag{ @@ -41,7 +41,7 @@ var cronInfoCmd = &cli.Command{ }, } -func cronInfo(ctx context.Context, c *cli.Command) error { +func cronShow(ctx context.Context, c *cli.Command) error { var ( cronID = c.Int("id") repoIDOrFullName = c.String("repository") diff --git a/cli/repo/registry/registry.go b/cli/repo/registry/registry.go index df3f0944682..98b4ef84afb 100644 --- a/cli/repo/registry/registry.go +++ b/cli/repo/registry/registry.go @@ -29,7 +29,7 @@ var Command = &cli.Command{ registryCreateCmd, registryDeleteCmd, registryUpdateCmd, - registryInfoCmd, + registryShowCmd, registryListCmd, }, } diff --git a/cli/repo/registry/registry_add.go b/cli/repo/registry/registry_add.go index e894a698c1b..50eecffa0c5 100644 --- a/cli/repo/registry/registry_add.go +++ b/cli/repo/registry/registry_add.go @@ -28,7 +28,7 @@ import ( var registryCreateCmd = &cli.Command{ Name: "add", - Usage: "adds a registry", + Usage: "add a registry", ArgsUsage: "[repo-id|repo-full-name]", Action: registryCreate, Flags: []cli.Flag{ diff --git a/cli/repo/registry/registry_info.go b/cli/repo/registry/registry_show.go similarity index 88% rename from cli/repo/registry/registry_info.go rename to cli/repo/registry/registry_show.go index f171d1d23a6..d3b50b9f2fb 100644 --- a/cli/repo/registry/registry_info.go +++ b/cli/repo/registry/registry_show.go @@ -25,11 +25,11 @@ import ( "go.woodpecker-ci.org/woodpecker/v2/cli/internal" ) -var registryInfoCmd = &cli.Command{ - Name: "info", - Usage: "display registry info", +var registryShowCmd = &cli.Command{ + Name: "show", + Usage: "show registry information", ArgsUsage: "[repo-id|repo-full-name]", - Action: registryInfo, + Action: registryShow, Flags: []cli.Flag{ common.RepoFlag, &cli.StringFlag{ @@ -41,7 +41,7 @@ var registryInfoCmd = &cli.Command{ }, } -func registryInfo(ctx context.Context, c *cli.Command) error { +func registryShow(ctx context.Context, c *cli.Command) error { var ( hostname = c.String("hostname") format = c.String("format") + "\n" diff --git a/cli/repo/repo.go b/cli/repo/repo.go index 6eeda1ddd64..e9467694cd7 100644 --- a/cli/repo/repo.go +++ b/cli/repo/repo.go @@ -28,7 +28,7 @@ var Command = &cli.Command{ Usage: "manage repositories", Commands: []*cli.Command{ repoListCmd, - repoInfoCmd, + repoShowCmd, repoAddCmd, repoUpdateCmd, repoRemoveCmd, diff --git a/cli/repo/repo_info.go b/cli/repo/repo_show.go similarity index 90% rename from cli/repo/repo_info.go rename to cli/repo/repo_show.go index 648766940d8..af8a45153d9 100644 --- a/cli/repo/repo_info.go +++ b/cli/repo/repo_show.go @@ -25,15 +25,15 @@ import ( "go.woodpecker-ci.org/woodpecker/v2/cli/internal" ) -var repoInfoCmd = &cli.Command{ - Name: "info", - Usage: "show repository details", +var repoShowCmd = &cli.Command{ + Name: "show", + Usage: "show repository information", ArgsUsage: "", - Action: repoInfo, + Action: repoShow, Flags: []cli.Flag{common.FormatFlag(tmplRepoInfo)}, } -func repoInfo(ctx context.Context, c *cli.Command) error { +func repoShow(ctx context.Context, c *cli.Command) error { repoIDOrFullName := c.Args().First() client, err := internal.NewClient(ctx, c) if err != nil { diff --git a/cli/repo/repo_update.go b/cli/repo/repo_update.go index c5fe2a23257..b6a2e58466d 100644 --- a/cli/repo/repo_update.go +++ b/cli/repo/repo_update.go @@ -53,7 +53,7 @@ var repoUpdateCmd = &cli.Command{ }, &cli.StringFlag{ Name: "config", - Usage: "repository configuration path (e.g. .woodpecker.yml)", + Usage: "repository configuration path. Example: .woodpecker.yml", }, &cli.IntFlag{ Name: "pipeline-counter", @@ -61,7 +61,7 @@ var repoUpdateCmd = &cli.Command{ }, &cli.BoolFlag{ Name: "unsafe", - Usage: "validate updating the pipeline-counter is unsafe", + Usage: "allow unsafe operations", }, }, } diff --git a/cli/repo/secret/secret.go b/cli/repo/secret/secret.go index 1ea67ea991a..3284539d37d 100644 --- a/cli/repo/secret/secret.go +++ b/cli/repo/secret/secret.go @@ -29,7 +29,7 @@ var Command = &cli.Command{ secretCreateCmd, secretDeleteCmd, secretUpdateCmd, - secretInfoCmd, + secretShowCmd, secretListCmd, }, } diff --git a/cli/repo/secret/secret_add.go b/cli/repo/secret/secret_add.go index ee883c06454..cc4251e204e 100644 --- a/cli/repo/secret/secret_add.go +++ b/cli/repo/secret/secret_add.go @@ -28,7 +28,7 @@ import ( var secretCreateCmd = &cli.Command{ Name: "add", - Usage: "adds a secret", + Usage: "add a secret", ArgsUsage: "[repo-id|repo-full-name]", Action: secretCreate, Flags: []cli.Flag{ @@ -43,11 +43,11 @@ var secretCreateCmd = &cli.Command{ }, &cli.StringSliceFlag{ Name: "event", - Usage: "secret limited to these events", + Usage: "limit secret to these events", }, &cli.StringSliceFlag{ Name: "image", - Usage: "secret limited to these images", + Usage: "limit secret to these images", }, }, } diff --git a/cli/repo/secret/secret_set.go b/cli/repo/secret/secret_set.go index 0b21d4b666b..60c0fcc8d01 100644 --- a/cli/repo/secret/secret_set.go +++ b/cli/repo/secret/secret_set.go @@ -43,11 +43,11 @@ var secretUpdateCmd = &cli.Command{ }, &cli.StringSliceFlag{ Name: "event", - Usage: "secret limited to these events", + Usage: "limit secret to these events", }, &cli.StringSliceFlag{ Name: "image", - Usage: "secret limited to these images", + Usage: "limit secret to these images", }, }, } diff --git a/cli/repo/secret/secret_info.go b/cli/repo/secret/secret_show.go similarity index 89% rename from cli/repo/secret/secret_info.go rename to cli/repo/secret/secret_show.go index fcb30db83ed..8387f405461 100644 --- a/cli/repo/secret/secret_info.go +++ b/cli/repo/secret/secret_show.go @@ -26,11 +26,11 @@ import ( "go.woodpecker-ci.org/woodpecker/v2/cli/internal" ) -var secretInfoCmd = &cli.Command{ - Name: "info", - Usage: "display secret info", +var secretShowCmd = &cli.Command{ + Name: "show", + Usage: "show secret information", ArgsUsage: "[repo-id|repo-full-name]", - Action: secretInfo, + Action: secretShow, Flags: []cli.Flag{ common.RepoFlag, &cli.StringFlag{ @@ -41,7 +41,7 @@ var secretInfoCmd = &cli.Command{ }, } -func secretInfo(ctx context.Context, c *cli.Command) error { +func secretShow(ctx context.Context, c *cli.Command) error { var ( secretName = c.String("name") format = c.String("format") + "\n" diff --git a/cli/setup/setup.go b/cli/setup/setup.go index 6705482e942..c0be0006a40 100644 --- a/cli/setup/setup.go +++ b/cli/setup/setup.go @@ -20,11 +20,11 @@ var Command = &cli.Command{ Flags: []cli.Flag{ &cli.StringFlag{ Name: "server", - Usage: "The URL of the woodpecker server", + Usage: "URL of the woodpecker server", }, &cli.StringFlag{ Name: "token", - Usage: "The token to authenticate with the woodpecker server", + Usage: "token to authenticate with the woodpecker server", }, }, Action: setup, @@ -41,7 +41,7 @@ func setup(ctx context.Context, c *cli.Command) error { } if !setupAgain { - log.Info().Msg("Configuration skipped") + log.Info().Msg("configuration skipped") return nil } } @@ -87,7 +87,7 @@ func setup(ctx context.Context, c *cli.Command) error { return err } - log.Info().Msg("The woodpecker-cli has been successfully setup") + log.Info().Msg("woodpecker-cli has been successfully setup") return nil } diff --git a/cli/setup/token_fetcher.go b/cli/setup/token_fetcher.go index 59be6b08d34..05305e7ca9f 100644 --- a/cli/setup/token_fetcher.go +++ b/cli/setup/token_fetcher.go @@ -24,12 +24,12 @@ func receiveTokenFromUI(c context.Context, serverURL string) (string, error) { srv.Handler = setupRouter(tokenReceived) go func() { - log.Debug().Msgf("Listening for token response on :%d", port) + log.Debug().Msgf("listening for token response on :%d", port) _ = srv.ListenAndServe() }() defer func() { - log.Debug().Msg("Shutting down server") + log.Debug().Msg("shutting down server") _ = srv.Shutdown(c) }() @@ -90,7 +90,7 @@ func setupRouter(tokenReceived chan string) *gin.Engine { err := c.BindJSON(&data) if err != nil { - log.Debug().Err(err).Msg("Failed to bind JSON") + log.Debug().Err(err).Msg("failed to bind JSON") c.JSON(http.StatusBadRequest, gin.H{ "error": "invalid request", }) @@ -110,7 +110,7 @@ func setupRouter(tokenReceived chan string) *gin.Engine { func openBrowser(url string) error { var err error - log.Debug().Msgf("Opening browser with URL: %s", url) + log.Debug().Msgf("opening browser with URL: %s", url) switch runtime.GOOS { case "linux": diff --git a/cli/update/command.go b/cli/update/command.go index ad856402f4f..a4dad8530e3 100644 --- a/cli/update/command.go +++ b/cli/update/command.go @@ -24,7 +24,7 @@ var Command = &cli.Command{ } func update(ctx context.Context, c *cli.Command) error { - log.Info().Msg("Checking for updates ...") + log.Info().Msg("checking for updates ...") newVersion, err := CheckForUpdate(ctx, c.Bool("force")) if err != nil { @@ -32,11 +32,11 @@ func update(ctx context.Context, c *cli.Command) error { } if newVersion == nil { - fmt.Println("You are using the latest version of woodpecker-cli") + fmt.Println("you are using the latest version of woodpecker-cli") return nil } - log.Info().Msgf("New version %s is available! Updating ...", newVersion.Version) + log.Info().Msgf("new version %s is available! Updating ...", newVersion.Version) var tarFilePath string tarFilePath, err = downloadNewVersion(ctx, newVersion.AssetURL) @@ -44,14 +44,14 @@ func update(ctx context.Context, c *cli.Command) error { return err } - log.Debug().Msgf("New version %s has been downloaded successfully! Installing ...", newVersion.Version) + log.Debug().Msgf("new version %s has been downloaded successfully! Installing ...", newVersion.Version) binFile, err := extractNewVersion(tarFilePath) if err != nil { return err } - log.Debug().Msgf("New version %s has been extracted to %s", newVersion.Version, binFile) + log.Debug().Msgf("new version %s has been extracted to %s", newVersion.Version, binFile) executablePathOrSymlink, err := os.Executable() if err != nil { diff --git a/cli/update/updater.go b/cli/update/updater.go index 9071e2605c6..d77bad6a452 100644 --- a/cli/update/updater.go +++ b/cli/update/updater.go @@ -22,10 +22,10 @@ func CheckForUpdate(ctx context.Context, force bool) (*NewVersion, error) { } func checkForUpdate(ctx context.Context, versionURL string, force bool) (*NewVersion, error) { - log.Debug().Msgf("Current version: %s", version.String()) + log.Debug().Msgf("current version: %s", version.String()) if (version.String() == "dev" || strings.HasPrefix(version.String(), "next-")) && !force { - log.Debug().Msgf("Skipping update check for development & next versions") + log.Debug().Msgf("skipping update check for development/next versions") return nil, nil } @@ -61,11 +61,11 @@ func checkForUpdate(ctx context.Context, versionURL string, force bool) (*NewVer // using the latest release if installedVersion == upstreamVersion && !force { - log.Debug().Msgf("No new version available") + log.Debug().Msgf("no new version available") return nil, nil } - log.Debug().Msgf("New version available: %s", upstreamVersion) + log.Debug().Msgf("new version available: %s", upstreamVersion) assetURL := fmt.Sprintf(githubBinaryURL, upstreamVersion, runtime.GOOS, runtime.GOARCH) return &NewVersion{ @@ -75,7 +75,7 @@ func checkForUpdate(ctx context.Context, versionURL string, force bool) (*NewVer } func downloadNewVersion(ctx context.Context, downloadURL string) (string, error) { - log.Debug().Msgf("Downloading new version from %s ...", downloadURL) + log.Debug().Msgf("downloading new version from %s ...", downloadURL) req, err := http.NewRequestWithContext(ctx, http.MethodGet, downloadURL, nil) if err != nil { @@ -102,13 +102,13 @@ func downloadNewVersion(ctx context.Context, downloadURL string) (string, error) return "", err } - log.Debug().Msgf("New version downloaded to %s", file.Name()) + log.Debug().Msgf("new version downloaded to %s", file.Name()) return file.Name(), nil } func extractNewVersion(tarFilePath string) (string, error) { - log.Debug().Msgf("Extracting new version from %s ...", tarFilePath) + log.Debug().Msgf("extracting new version from %s ...", tarFilePath) tarFile, err := os.Open(tarFilePath) if err != nil { @@ -132,7 +132,7 @@ func extractNewVersion(tarFilePath string) (string, error) { return "", err } - log.Debug().Msgf("New version extracted to %s", tmpDir) + log.Debug().Msgf("new version extracted to %s", tmpDir) return path.Join(tmpDir, "woodpecker-cli"), nil } diff --git a/docs/src/pages/migrations.md b/docs/src/pages/migrations.md index a45c6cca156..dcafbd8313b 100644 --- a/docs/src/pages/migrations.md +++ b/docs/src/pages/migrations.md @@ -43,6 +43,7 @@ This will be the next version of Woodpecker. - `woodpecker-cli cron` is now `woodpecker-cli repo cron` - `woodpecker-cli secret [add|rm|...] --repository` is now `woodpecker-cli repo secret [add|rm|...]` - `woodpecker-cli pipeline logs` is now `woodpecker-cli pipeline log show` + - `woodpecker-cli [registry|secret|...] info` is now `woodpecker-cli [registry|secret|...] show` ## Admin migrations