~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/romulus/cmd/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 2016 Canonical Ltd.
 
2
// Licensed under the AGPLv3, see LICENCE file for details.
 
3
 
 
4
// Package commands provides functionality for registering all the romulus commands.
 
5
package commands
 
6
 
 
7
import (
 
8
        "github.com/juju/cmd"
 
9
        "github.com/juju/juju/cmd/modelcmd"
 
10
 
 
11
        "github.com/juju/romulus/cmd/agree"
 
12
        "github.com/juju/romulus/cmd/allocate"
 
13
        "github.com/juju/romulus/cmd/createbudget"
 
14
        "github.com/juju/romulus/cmd/listagreements"
 
15
        "github.com/juju/romulus/cmd/listbudgets"
 
16
        "github.com/juju/romulus/cmd/listplans"
 
17
        "github.com/juju/romulus/cmd/setbudget"
 
18
        "github.com/juju/romulus/cmd/setplan"
 
19
        "github.com/juju/romulus/cmd/showbudget"
 
20
        "github.com/juju/romulus/cmd/updateallocation"
 
21
)
 
22
 
 
23
type commandRegister interface {
 
24
        Register(cmd.Command)
 
25
}
 
26
 
 
27
// RegisterAll registers all romulus commands with the
 
28
// provided command registry.
 
29
func RegisterAll(r commandRegister) {
 
30
        register := func(c cmd.Command) {
 
31
                switch c := c.(type) {
 
32
                case modelcmd.ModelCommand:
 
33
                        r.Register(modelcmd.Wrap(c))
 
34
                case modelcmd.CommandBase:
 
35
                        r.Register(modelcmd.WrapBase(c))
 
36
                default:
 
37
                        r.Register(c)
 
38
                }
 
39
 
 
40
        }
 
41
        register(agree.NewAgreeCommand())
 
42
        register(listagreements.NewListAgreementsCommand())
 
43
        register(allocate.NewAllocateCommand())
 
44
        register(listbudgets.NewListBudgetsCommand())
 
45
        register(createbudget.NewCreateBudgetCommand())
 
46
        register(listplans.NewListPlansCommand())
 
47
        register(setbudget.NewSetBudgetCommand())
 
48
        register(setplan.NewSetPlanCommand())
 
49
        register(showbudget.NewShowBudgetCommand())
 
50
        register(updateallocation.NewUpdateAllocationCommand())
 
51
}