From 4ecb6360ebda360bbfad0c27f1dfb6dcb4d56d8e Mon Sep 17 00:00:00 2001 From: Yan Su Date: Tue, 21 Sep 2021 19:33:43 +0900 Subject: [PATCH] add `-show-url` option for `ui` command --- command/ui.go | 8 +++++++- website/content/docs/commands/ui.mdx | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/command/ui.go b/command/ui.go index d4d275dbb52b..ad1c9b730596 100644 --- a/command/ui.go +++ b/command/ui.go @@ -35,6 +35,8 @@ UI Options -authenticate: Exchange your Nomad ACL token for a one-time token in the web UI, if ACLs are enabled. + + -show-url: Show the url instead of opening with default browser. ` return strings.TrimSpace(helpText) @@ -82,10 +84,12 @@ func (c *UiCommand) Name() string { return "ui" } func (c *UiCommand) Run(args []string) int { var authenticate bool + var showUrl bool flags := c.Meta.FlagSet(c.Name(), FlagSetClient) flags.Usage = func() { c.Ui.Output(c.Help()) } flags.BoolVar(&authenticate, "authenticate", false, "") + flags.BoolVar(&showUrl, "show-url", false, "") if err := flags.Parse(args); err != nil { return 1 @@ -184,7 +188,9 @@ func (c *UiCommand) Run(args []string) int { } else { c.Ui.Output(fmt.Sprintf("Opening URL %q", url.String())) } - if err := open.Start(url.String()); err != nil { + if showUrl { + c.Ui.Output(fmt.Sprintf("URL for web UI: %s", url.String())) + } else if err := open.Start(url.String()); err != nil { c.Ui.Error(fmt.Sprintf("Error opening URL: %s", err)) return 1 } diff --git a/website/content/docs/commands/ui.mdx b/website/content/docs/commands/ui.mdx index 21bc2decc624..eefc8008b2ff 100644 --- a/website/content/docs/commands/ui.mdx +++ b/website/content/docs/commands/ui.mdx @@ -36,6 +36,8 @@ storage for authentication. - `-authenticate`: Exchange your Nomad ACL token for a one-time token in the web UI. +- `-show-url`: Show the url instead of opening with default browser. + ## Examples Open the UI homepage: