Skip to content

Commit

Permalink
add -show-url option for ui command
Browse files Browse the repository at this point in the history
  • Loading branch information
yaroot committed Sep 21, 2021
1 parent d7f9180 commit 4ecb636
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion command/ui.go
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions website/content/docs/commands/ui.mdx
Expand Up @@ -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:
Expand Down

0 comments on commit 4ecb636

Please sign in to comment.