Skip to content

Commit

Permalink
Merge pull request superfly#1531 from ndarilek/to-show
Browse files Browse the repository at this point in the history
Replace various `view`/`display` commands with `show` for consistency
  • Loading branch information
ndarilek authored Jan 12, 2023
2 parents 352bd3e + d191692 commit be13c02
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 25 deletions.
7 changes: 4 additions & 3 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ func newConfigCommand(client *client.Client) *Command {

cmd := BuildCommandKS(nil, nil, configStrings, client, requireSession, requireAppName)

configDisplayStrings := docstrings.Get("config.display")
BuildCommandKS(cmd, runDisplayConfig, configDisplayStrings, client, requireSession, requireAppName)
configShowStrings := docstrings.Get("config.show")
cmdShow := BuildCommandKS(cmd, runShowConfig, configShowStrings, client, requireSession, requireAppName)
cmdShow.Aliases = []string{"display"}

configSaveStrings := docstrings.Get("config.save")
BuildCommandKS(cmd, runSaveConfig, configSaveStrings, client, requireSession, requireAppName)
Expand All @@ -36,7 +37,7 @@ func newConfigCommand(client *client.Client) *Command {
return cmd
}

func runDisplayConfig(cmdCtx *cmdctx.CmdContext) error {
func runShowConfig(cmdCtx *cmdctx.CmdContext) error {
ctx := cmdCtx.Command.Context()

cfg, err := cmdCtx.Client.API().GetConfig(ctx, cmdCtx.AppName)
Expand Down
6 changes: 3 additions & 3 deletions docstrings/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ Takes hostname as a parameter to locate the certificate.`,
return KeyStrings{"config", "Manage an app's configuration",
`The CONFIG commands allow you to work with an application's configuration.`,
}
case "config.display":
return KeyStrings{"display", "Display an app's configuration",
`Display an application's configuration. The configuration is presented
case "config.show":
return KeyStrings{"show", "Show an app's configuration",
`Show an application's configuration. The configuration is presented
in JSON format. The configuration data is retrieved from the Fly service.`,
}
case "config.env":
Expand Down
8 changes: 4 additions & 4 deletions helpgen/flyctlhelp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,12 @@ longHelp = """The CONFIG commands allow you to work with an application's config
"""
shortHelp = "Manage an app's configuration"
usage = "config"
[config.display]
longHelp = """Display an application's configuration. The configuration is presented
[config.show]
longHelp = """Show an application's configuration. The configuration is presented
in JSON format. The configuration data is retrieved from the Fly service.
"""
shortHelp = "Display an app's configuration"
usage = "display"
shortHelp = "Show an app's configuration"
usage = "show"
[config.save]
longHelp = """Save an application's configuration locally. The configuration data is
retrieved from the Fly service and saved in TOML format.
Expand Down
4 changes: 2 additions & 2 deletions internal/command/postgres/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ var pgSettings = map[string]string{

func newConfig() (cmd *cobra.Command) {
const (
short = "View and manage Postgres configuration."
short = "Show and manage Postgres configuration."
long = short + "\n"
)

cmd = command.New("config", short, long, nil)

cmd.AddCommand(
newConfigView(),
newConfigShow(),
newConfigUpdate(),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@ import (
"github.com/superfly/flyctl/iostreams"
)

func newConfigView() (cmd *cobra.Command) {
func newConfigShow() (cmd *cobra.Command) {
const (
long = `View your Postgres configuration`
short = "View your Postgres configuration"
usage = "view"
long = `Show Postgres configuration`
short = "Show Postgres configuration"
usage = "show"
)

cmd = command.New(usage, short, long, runConfigView,
cmd = command.New(usage, short, long, runConfigShow,
command.RequireSession,
command.RequireAppName,
)

cmd.Aliases = []string{"view"}

flag.Add(cmd,
flag.App(),
flag.AppConfig(),
Expand All @@ -41,7 +43,7 @@ func newConfigView() (cmd *cobra.Command) {
return
}

func runConfigView(ctx context.Context) error {
func runConfigShow(ctx context.Context) error {
var (
client = client.FromContext(ctx).API()
appName = app.NameFromContext(ctx)
Expand All @@ -63,15 +65,15 @@ func runConfigView(ctx context.Context) error {

switch app.PlatformVersion {
case "machines":
return runMachineConfigView(ctx, app)
return runMachineConfigShow(ctx, app)
case "nomad":
return runNomadConfigView(ctx, app)
return runNomadConfigShow(ctx, app)
default:
return fmt.Errorf("unknown platform version")
}
}

func runMachineConfigView(ctx context.Context, app *api.AppCompact) (err error) {
func runMachineConfigShow(ctx context.Context, app *api.AppCompact) (err error) {
var (
MinPostgresHaVersion = "0.0.19"
MinPostgresStandaloneVersion = "0.0.7"
Expand Down Expand Up @@ -101,10 +103,10 @@ func runMachineConfigView(ctx context.Context, app *api.AppCompact) (err error)
return err
}

return viewSettings(ctx, app, leader.PrivateIP)
return showSettings(ctx, app, leader.PrivateIP)
}

func runNomadConfigView(ctx context.Context, app *api.AppCompact) (err error) {
func runNomadConfigShow(ctx context.Context, app *api.AppCompact) (err error) {
var (
MinPostgresHaVersion = "0.0.19"
client = client.FromContext(ctx).API()
Expand Down Expand Up @@ -133,10 +135,10 @@ func runNomadConfigView(ctx context.Context, app *api.AppCompact) (err error) {
return err
}

return viewSettings(ctx, app, leaderIP)
return showSettings(ctx, app, leaderIP)
}

func viewSettings(ctx context.Context, app *api.AppCompact, leaderIP string) error {
func showSettings(ctx context.Context, app *api.AppCompact, leaderIP string) error {
var (
io = iostreams.FromContext(ctx)
colorize = io.ColorScheme()
Expand Down

0 comments on commit be13c02

Please sign in to comment.