github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/cmd/juju/romulus/commands/commands.go (about)

     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  
    10  	"github.com/juju/juju/cmd/juju/romulus/agree"
    11  	"github.com/juju/juju/cmd/juju/romulus/allocate"
    12  	"github.com/juju/juju/cmd/juju/romulus/createbudget"
    13  	"github.com/juju/juju/cmd/juju/romulus/listagreements"
    14  	"github.com/juju/juju/cmd/juju/romulus/listbudgets"
    15  	"github.com/juju/juju/cmd/juju/romulus/listplans"
    16  	"github.com/juju/juju/cmd/juju/romulus/setbudget"
    17  	"github.com/juju/juju/cmd/juju/romulus/setplan"
    18  	"github.com/juju/juju/cmd/juju/romulus/showbudget"
    19  	"github.com/juju/juju/cmd/juju/romulus/updateallocation"
    20  	"github.com/juju/juju/cmd/modelcmd"
    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  }