Skip to content

Commit

Permalink
Merge pull request #1181 from hashicorp/f-plan-cli
Browse files Browse the repository at this point in the history
cli: nomad plan command
  • Loading branch information
dadgar committed May 25, 2016
2 parents 8108859 + 0a6c5ba commit 0c0f64a
Show file tree
Hide file tree
Showing 9 changed files with 866 additions and 1 deletion.
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

0 comments on commit 0c0f64a

Please sign in to comment.