github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/cmd/juju/commands/commands.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package commands 5 6 import ( 7 "github.com/juju/cmd" 8 9 "github.com/juju/juju/cmd/modelcmd" 10 ) 11 12 // TODO(ericsnow) Replace all this with a better registry mechanism, 13 // likely over in the cmd repo. 14 15 var ( 16 registeredCommands []func() cmd.Command 17 registeredEnvCommands []func() modelcmd.ModelCommand 18 ) 19 20 // RegisterCommand adds the provided func to the set of those that will 21 // be called when the juju command runs. Each returned command will be 22 // registered with the "juju" supercommand. 23 func RegisterCommand(newCommand func() cmd.Command) { 24 registeredCommands = append(registeredCommands, newCommand) 25 } 26 27 // RegisterEnvCommand adds the provided func to the set of those that will 28 // be called when the juju command runs. Each returned command will be 29 // wrapped in envCmdWrapper, which is what gets registered with the 30 // "juju" supercommand. 31 func RegisterEnvCommand(newCommand func() modelcmd.ModelCommand) { 32 registeredEnvCommands = append(registeredEnvCommands, newCommand) 33 }