From c6243a2de78789b4de58275a98e97611a9fee21b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 5 Sep 2014 16:05:02 -0700 Subject: [PATCH] command/build: -color [GH-1433] --- CHANGELOG.md | 7 ++++--- command/build/command.go | 15 +++++++++------ .../source/docs/command-line/build.html.markdown | 2 ++ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e9312e72..ac355d772 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,8 +15,6 @@ FEATURES: Packer will look in the PWD and the directory with `packer` for binaries named `packer-TYPE-NAME`. * builder/docker: Images can now be committed instead of exported. [GH-1198] - * builder/docker: Can now specify login credentials to pull images. - * builder/docker: Support mounting additional volumes. [GH-1430] * builder/virtualbox-ovf: New `import_flags` setting can be used to add new command line flags to `VBoxManage import` to allow things such as EULAs to be accepted. [GH-1383] @@ -25,7 +23,6 @@ FEATURES: * builder/vmware: VMware Player 6 is now supported. [GH-1168] * builder/vmware-vmx: Boot commands and the HTTP server are supported. [GH-1169] - * post-processor/docker-push: Can now specify login credentials. [GH-1243] IMPROVEMENTS: @@ -37,6 +34,8 @@ IMPROVEMENTS: * builder/amazon-instance: EBS AMIs can be used as a source. [GH-1453] * builder/digitalocean: Can set API URL endpoint. [GH-1448] * builder/digitalocean: Region supports variables. [GH-1452] + * builder/docker: Can now specify login credentials to pull images. + * builder/docker: Support mounting additional volumes. [GH-1430] * builder/parallels/all: Path to tools ISO is calculated automatically. [GH-1455] * builder/parallels-pvm: `reassign_mac` option to choose wehther or not to generate a new MAC address. [GH-1461] @@ -44,6 +43,8 @@ IMPROVEMENTS: * builder/qemu: Can specify "tcg" acceleration type. [GH-1395] * builder/virtualbox/all: `iso_interface` option to mount ISO with SATA. [GH-1200] * builder/vmware-vmx: Proper `floppy_files` support. [GH-1057] + * command/build: Add `-color=false` flag to disable color. [GH-1433] + * post-processor/docker-push: Can now specify login credentials. [GH-1243] BUG FIXES: diff --git a/command/build/command.go b/command/build/command.go index 2b3ceb394..ee2119a22 100644 --- a/command/build/command.go +++ b/command/build/command.go @@ -21,13 +21,12 @@ func (Command) Help() string { } func (c Command) Run(env packer.Environment, args []string) int { - var cfgDebug bool - var cfgForce bool - var cfgParallel bool + var cfgColor, cfgDebug, cfgForce, cfgParallel bool buildOptions := new(cmdcommon.BuildOptions) cmdFlags := flag.NewFlagSet("build", flag.ContinueOnError) cmdFlags.Usage = func() { env.Ui().Say(c.Help()) } + cmdFlags.BoolVar(&cfgColor, "color", true, "enable or disable color") cmdFlags.BoolVar(&cfgDebug, "debug", false, "debug mode for builds") cmdFlags.BoolVar(&cfgForce, "force", false, "force a build if artifacts exist") cmdFlags.BoolVar(&cfgParallel, "parallel", true, "enable/disable parallelization") @@ -95,9 +94,13 @@ func (c Command) Run(env packer.Environment, args []string) int { buildUis := make(map[string]packer.Ui) for i, b := range builds { - ui := &packer.ColoredUi{ - Color: colors[i%len(colors)], - Ui: env.Ui(), + var ui packer.Ui + ui = env.Ui() + if cfgColor { + ui = &packer.ColoredUi{ + Color: colors[i%len(colors)], + Ui: env.Ui(), + } } buildUis[b.Name()] = ui diff --git a/website/source/docs/command-line/build.html.markdown b/website/source/docs/command-line/build.html.markdown index ff111b477..d1b9bf2e8 100644 --- a/website/source/docs/command-line/build.html.markdown +++ b/website/source/docs/command-line/build.html.markdown @@ -12,6 +12,8 @@ artifacts that are created will be outputted at the end of the build. ## Options +* `-color=false` - Disables colorized output. Enabled by default. + * `-debug` - Disables parallelization and enables debug mode. Debug mode flags the builders that they should output debugging information. The exact behavior of debug mode is left to the builder. In general, builders usually will stop