// NewEnvironmentsCommand returns a EnvironmentsCommand with the API and userCreds // provided as specified. func NewEnvironmentsCommand(envAPI EnvironmentsEnvAPI, sysAPI EnvironmentsSysAPI, userCreds *configstore.APICredentials) cmd.Command { return envcmd.WrapSystem(&environmentsCommand{ envAPI: envAPI, sysAPI: sysAPI, userCreds: userCreds, }) }
// NewCreateEnvironmentCommand returns a CreateEnvironmentCommand with the api provided as specified. func NewCreateEnvironmentCommand(api CreateEnvironmentAPI, parser func(interface{}) (interface{}, error)) (cmd.Command, *CreateEnvironmentCommand) { c := &createEnvironmentCommand{ api: api, configParser: parser, } return envcmd.WrapSystem(c), &CreateEnvironmentCommand{c} }
// NewChangePasswordCommand returns a ChangePasswordCommand with the api // and writer provided as specified. func NewChangePasswordCommand(api ChangePasswordAPI, writer EnvironInfoCredsWriter) (cmd.Command, *ChangePasswordCommand) { c := &changePasswordCommand{ api: api, writer: writer, } return envcmd.WrapSystem(c), &ChangePasswordCommand{c} }
// NewUseEnvironmentCommand returns a UseEnvironmentCommand with the API and // userCreds provided as specified. func NewUseEnvironmentCommand(api UseEnvironmentAPI, userCreds *configstore.APICredentials, endpoint *configstore.APIEndpoint) (cmd.Command, *UseEnvironmentCommand) { c := &useEnvironmentCommand{ api: api, userCreds: userCreds, endpoint: endpoint, } return envcmd.WrapSystem(c), &UseEnvironmentCommand{c} }
// NewEnableCommand returns a EnableCommand with the api provided as // specified. func NewEnableCommand(api disenableUserAPI) (cmd.Command, *DisenableUserBase) { c := &enableCommand{ disenableUserBase{ api: api, }, } return envcmd.WrapSystem(c), &DisenableUserBase{&c.disenableUserBase} }
// NewListCommand returns a ListCommand with the api provided as specified. func NewListCommand(api UserInfoAPI) cmd.Command { c := &listCommand{ infoCommandBase: infoCommandBase{ api: api, }, } return envcmd.WrapSystem(c) }
// NewSuperCommand creates the system supercommand and registers the // subcommands that it supports. func NewSuperCommand() cmd.Command { systemCmd := cmd.NewSuperCommand(cmd.SuperCommandParams{ Name: "system", Doc: commandDoc, UsagePrefix: "juju", Purpose: "manage systems", }) systemCmd.Register(&ListCommand{}) systemCmd.Register(&LoginCommand{}) systemCmd.Register(&DestroyCommand{}) systemCmd.Register(&KillCommand{apiDialerFunc: juju.NewAPIFromName}) systemCmd.Register(envcmd.WrapSystem(&EnvironmentsCommand{})) systemCmd.Register(envcmd.WrapSystem(&CreateEnvironmentCommand{})) systemCmd.Register(envcmd.WrapSystem(&RemoveBlocksCommand{})) systemCmd.Register(envcmd.WrapSystem(&UseEnvironmentCommand{})) return systemCmd }
// NewSuperCommand creates the user supercommand and registers the subcommands // that it supports. func NewSuperCommand() cmd.Command { usercmd := cmd.NewSuperCommand(cmd.SuperCommandParams{ Name: "user", Doc: userCommandDoc, UsagePrefix: "juju", Purpose: userCommandPurpose, }) usercmd.Register(envcmd.WrapSystem(&AddCommand{})) usercmd.Register(envcmd.WrapSystem(&ChangePasswordCommand{})) usercmd.Register(envcmd.WrapSystem(&CredentialsCommand{})) usercmd.Register(envcmd.WrapSystem(&InfoCommand{})) usercmd.Register(envcmd.WrapSystem(&DisableCommand{})) usercmd.Register(envcmd.WrapSystem(&EnableCommand{})) usercmd.Register(envcmd.WrapSystem(&ListCommand{})) return usercmd }
func newEnableCommand() cmd.Command { return envcmd.WrapSystem(&enableCommand{}) }
func newUseEnvironmentCommand() cmd.Command { return envcmd.WrapSystem(&useEnvironmentCommand{}) }
func newDisableCommand() cmd.Command { return envcmd.WrapSystem(&disableCommand{}) }
func (s *SystemCommandSuite) TestWrapWithoutFlags(c *gc.C) { cmd := new(testSystemCommand) wrapped := envcmd.WrapSystem(cmd, envcmd.SystemSkipFlags) err := cmdtesting.InitCommand(wrapped, []string{"-s", "testsys"}) c.Assert(err, gc.ErrorMatches, "flag provided but not defined: -s") }
func (s *createSuite) run(c *gc.C, args ...string) (*cmd.Context, error) { command := system.NewCreateEnvironmentCommand(s.fake) return testing.RunCommand(c, envcmd.WrapSystem(command), args...) }
func newCreateEnvironmentCommand() cmd.Command { return envcmd.WrapSystem(&createEnvironmentCommand{}) }
func (s *CredentialsCommandSuite) run(c *gc.C, args ...string) (*cmd.Context, error) { command := envcmd.WrapSystem(&user.CredentialsCommand{}) return testing.RunCommand(c, command, args...) }
func (s *UserAddCommandSuite) run(c *gc.C, args ...string) (*cmd.Context, error) { addCommand := envcmd.WrapSystem(user.NewAddCommand(s.mockAPI)) return testing.RunCommand(c, addCommand, args...) }
func newInfoCommand() cmd.Command { return envcmd.WrapSystem(&infoCommand{}) }
// NewRemoveBlocksCommand returns a RemoveBlocksCommand with the function used // to open the API connection mocked out. func NewRemoveBlocksCommand(api removeBlocksAPI) cmd.Command { return envcmd.WrapSystem(&removeBlocksCommand{ api: api, }) }
// NewListBlocksCommand returns a ListBlocksCommand with the systemmanager // endpoint mocked out. func NewListBlocksCommand(api listBlocksAPI, apierr error) cmd.Command { return envcmd.WrapSystem(&listBlocksCommand{ api: api, apierr: apierr, }) }
func NewCredentialsCommand() (cmd.Command, *CredentialsCommand) { c := &credentialsCommand{} return envcmd.WrapSystem(c), &CredentialsCommand{c} }
func NewInfoCommand(api UserInfoAPI) cmd.Command { return envcmd.WrapSystem(&infoCommand{ infoCommandBase: infoCommandBase{ api: api, }}) }
func NewAddCommand(api AddUserAPI) (cmd.Command, *AddCommand) { c := &addCommand{api: api} return envcmd.WrapSystem(c), &AddCommand{c} }
func (s *UseEnvironmentSuite) run(c *gc.C, args ...string) (*cmd.Context, error) { command := system.NewUseEnvironmentCommand(s.api, &s.creds, &s.endpoint) return testing.RunCommand(c, envcmd.WrapSystem(command), args...) }
func (s *ChangePasswordCommandSuite) run(c *gc.C, args ...string) (*cmd.Context, error) { changePasswordCommand := envcmd.WrapSystem(user.NewChangePasswordCommand(s.mockAPI, s.mockEnvironInfo)) return testing.RunCommand(c, changePasswordCommand, args...) }
func newEnvironmentsCommand() cmd.Command { return envcmd.WrapSystem(&environmentsCommand{}) }
func newAddCommand() cmd.Command { return envcmd.WrapSystem(&addCommand{}) }
func initTestSystemCommand(c *gc.C, args ...string) (*testSystemCommand, error) { cmd := new(testSystemCommand) wrapped := envcmd.WrapSystem(cmd) return cmd, cmdtesting.InitCommand(wrapped, args) }
func newListBlocksCommand() cmd.Command { return envcmd.WrapSystem(&listBlocksCommand{}) }
func newRemoveBlocksCommand() cmd.Command { return envcmd.WrapSystem(&removeBlocksCommand{}) }
func newCredentialsCommand() cmd.Command { return envcmd.WrapSystem(&credentialsCommand{}) }