diff --git a/command/build/command.go b/command/build/command.go new file mode 100644 index 000000000..dfb8df60b --- /dev/null +++ b/command/build/command.go @@ -0,0 +1,15 @@ +package build + +import "fmt" +import "github.com/mitchellh/packer/packer" + +type Command byte + +func (Command) Run(env *packer.Environment, arg []string) int { + fmt.Println("HI!") + return 0 +} + +func (Command) Synopsis() string { + return "build image(s) from tempate" +} diff --git a/packer.go b/packer.go index 8488522c2..6dcec8153 100644 --- a/packer.go +++ b/packer.go @@ -3,12 +3,16 @@ package main import ( "github.com/mitchellh/packer/packer" + "github.com/mitchellh/packer/command/build" "fmt" "os" ) func main() { - env, err := packer.NewEnvironment(packer.DefaultEnvironmentConfig()) + envConfig := packer.DefaultEnvironmentConfig() + envConfig.Command["build"] = new(build.Command) + + env, err := packer.NewEnvironment(envConfig) if err != nil { fmt.Fprintf(os.Stderr, "Packer initialization error: \n\n%s\n", err) os.Exit(1) diff --git a/packer/environment.go b/packer/environment.go index 7caa96fba..0179fd979 100644 --- a/packer/environment.go +++ b/packer/environment.go @@ -34,6 +34,7 @@ type EnvironmentConfig struct { func DefaultEnvironmentConfig() *EnvironmentConfig { config := &EnvironmentConfig{} config.BuilderFactory = new(NilBuilderFactory) + config.Command = make(map[string]Command) config.Ui = &ReaderWriterUi{os.Stdin, os.Stdout} return config } diff --git a/packer/environment_test.go b/packer/environment_test.go index 63d5a8127..673e40beb 100644 --- a/packer/environment_test.go +++ b/packer/environment_test.go @@ -40,6 +40,13 @@ func testEnvironment() *Environment { return env } +func TestEnvironment_DefaultConfig_Command(t *testing.T) { + assert := asserts.NewTestingAsserts(t, true) + + config := DefaultEnvironmentConfig() + assert.NotNil(config.Command, "default Command should not be nil") +} + func TestEnvironment_DefaultConfig_Ui(t *testing.T) { assert := asserts.NewTestingAsserts(t, true)