Skip to content

Commit

Permalink
command: move all remaining commands
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Oct 28, 2014
1 parent 8054e66 commit fa36cf8
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 62 deletions.
49 changes: 39 additions & 10 deletions command/fix/command.go → command/fix.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
package fix
package command

import (
"bytes"
"encoding/json"
"flag"
"fmt"
"github.com/mitchellh/packer/packer"
"log"
"os"
"strings"
)

type Command byte
"github.com/mitchellh/packer/fix"
)

func (Command) Help() string {
return strings.TrimSpace(helpString)
type FixCommand struct {
Meta
}

func (c Command) Run(env packer.Environment, args []string) int {
func (c *FixCommand) Run(args []string) int {
env, err := c.Meta.Environment()
if err != nil {
c.Ui.Error(fmt.Sprintf("Error initializing environment: %s", err))
return 1
}

cmdFlags := flag.NewFlagSet("fix", flag.ContinueOnError)
cmdFlags.Usage = func() { env.Ui().Say(c.Help()) }
if err := cmdFlags.Parse(args); err != nil {
Expand Down Expand Up @@ -50,9 +55,9 @@ func (c Command) Run(env packer.Environment, args []string) int {
tplF.Close()

input := templateData
for _, name := range FixerOrder {
for _, name := range fix.FixerOrder {
var err error
fixer, ok := Fixers[name]
fixer, ok := fix.Fixers[name]
if !ok {
panic("fixer not found: " + name)
}
Expand Down Expand Up @@ -85,6 +90,30 @@ func (c Command) Run(env packer.Environment, args []string) int {
return 0
}

func (c Command) Synopsis() string {
func (*FixCommand) Help() string {
helpText := `
Usage: packer fix [options] TEMPLATE
Reads the JSON template and attempts to fix known backwards
incompatibilities. The fixed template will be outputted to standard out.
If the template cannot be fixed due to an error, the command will exit
with a non-zero exit status. Error messages will appear on standard error.
Fixes that are run:
iso-md5 Replaces "iso_md5" in builders with newer "iso_checksum"
createtime Replaces ".CreateTime" in builder configs with "{{timestamp}}"
virtualbox-gaattach Updates VirtualBox builders using "guest_additions_attach"
to use "guest_additions_mode"
pp-vagrant-override Replaces old-style provider overrides for the Vagrant
post-processor to new-style as of Packer 0.5.0.
virtualbox-rename Updates "virtualbox" builders to "virtualbox-iso"
`

return strings.TrimSpace(helpText)
}

func (c *FixCommand) Synopsis() string {
return "fixes templates from old versions of packer"
}
14 changes: 0 additions & 14 deletions command/fix/command_test.go

This file was deleted.

22 changes: 0 additions & 22 deletions command/fix/help.go

This file was deleted.

6 changes: 6 additions & 0 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ func init() {
}, nil
},

"fix": func() (cli.Command, error) {
return &command.FixCommand{
Meta: meta,
}, nil
},

"inspect": func() (cli.Command, error) {
return &command.InspectCommand{
Meta: meta,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 0 additions & 15 deletions plugin/command-fix/main.go

This file was deleted.

1 change: 0 additions & 1 deletion plugin/command-fix/main_test.go

This file was deleted.

0 comments on commit fa36cf8

Please sign in to comment.