~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/cmd/juju/commands/commands.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}