Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: nomad plan command #1181

Merged
merged 9 commits into from
May 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions command/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/hashicorp/nomad/api"
"github.com/mitchellh/cli"
"github.com/mitchellh/colorstring"
)

const (
Expand Down Expand Up @@ -38,6 +39,9 @@ type Meta struct {

// These are set by the command line flags.
flagAddress string

// Whether to not-colorize output
noColor bool
}

// FlagSet returns a FlagSet with the common flags that every
Expand All @@ -51,6 +55,7 @@ func (m *Meta) FlagSet(n string, fs FlagSetFlags) *flag.FlagSet {
// client connectivity options.
if fs&FlagSetClient != 0 {
f.StringVar(&m.flagAddress, "address", "", "")
f.BoolVar(&m.noColor, "no-color", false, "")
}

// Create an io.Writer that writes to our UI properly for errors.
Expand Down Expand Up @@ -82,6 +87,14 @@ func (m *Meta) Client() (*api.Client, error) {
return api.NewClient(config)
}

func (m *Meta) Colorize() *colorstring.Colorize {
return &colorstring.Colorize{
Colors: colorstring.DefaultColors,
Disable: m.noColor,
Reset: true,
}
}

// generalOptionsUsage returns the help string for the global options.
func generalOptionsUsage() string {
helpText := `
Expand Down
2 changes: 1 addition & 1 deletion command/meta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestMeta_FlagSet(t *testing.T) {
},
{
FlagSetClient,
[]string{"address"},
[]string{"address", "no-color"},
},
}

Expand Down
Loading