packer, etc: added Help method to Command interface

This will be used for long-form help when "packer help foo"
or "packer foo --help" is called.
This commit is contained in:
Mitchell Hashimoto
2013-06-02 11:41:12 -07:00
parent cf732a913d
commit bbafcfa938
9 changed files with 81 additions and 11 deletions
+4
View File
@@ -10,6 +10,10 @@ import (
type Command byte
func (Command) Help() string {
return "help"
}
func (Command) Run(env packer.Environment, args []string) int {
if len(args) != 1 {
env.Ui().Error("A single template argument is required.")
+7
View File
@@ -22,6 +22,13 @@ func testEnvironment() packer.Environment {
return env
}
func TestCommand_Implements(t *testing.T) {
assert := asserts.NewTestingAsserts(t, true)
var actual packer.Command
assert.Implementor(new(Command), &actual, "should be a Command")
}
func TestCommand_Run_NoArgs(t *testing.T) {
assert := asserts.NewTestingAsserts(t, true)
command := new(Command)