command/build: -color [GH-1433]

This commit is contained in:
Mitchell Hashimoto 2014-09-05 16:05:02 -07:00
parent b085c1d934
commit c6243a2de7
3 changed files with 15 additions and 9 deletions

View File

@ -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:

View File

@ -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

View File

@ -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