github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/cmd/juju/machine/list.go (about) 1 // Copyright 2016 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package machine 5 6 import ( 7 "github.com/juju/cmd" 8 "github.com/juju/errors" 9 10 "github.com/juju/juju/cmd/modelcmd" 11 ) 12 13 var usageListMachinesSummary = ` 14 Lists machines in a model.`[1:] 15 16 var usageListMachinesDetails = ` 17 By default, the tabular format is used. 18 The following sections are included: ID, STATE, DNS, INS-ID, SERIES, AZ 19 Note: AZ above is the cloud region's availability zone. 20 21 Examples: 22 juju list-machines 23 24 See also: 25 status` 26 27 // NewListMachineCommand returns a command that lists the machines in a model. 28 func NewListMachinesCommand() cmd.Command { 29 return modelcmd.Wrap(newListMachinesCommand(nil)) 30 } 31 32 func newListMachinesCommand(api statusAPI) *listMachinesCommand { 33 listCmd := &listMachinesCommand{} 34 listCmd.defaultFormat = "tabular" 35 listCmd.api = api 36 return listCmd 37 } 38 39 // listMachineCommand holds infomation about machines in a model. 40 type listMachinesCommand struct { 41 baselistMachinesCommand 42 } 43 44 // Info implements Command.Info. 45 func (c *listMachinesCommand) Info() *cmd.Info { 46 return &cmd.Info{ 47 Name: "list-machines", 48 Purpose: usageListMachinesSummary, 49 Doc: usageListMachinesDetails, 50 Aliases: []string{"machines", "machine", "list-machine"}, 51 } 52 } 53 54 // Init ensures the list-machines Command does not take arguments. 55 func (c *listMachinesCommand) Init(args []string) (err error) { 56 if args != nil { 57 return errors.Errorf("The list-machines command does not take any arguments") 58 } 59 return nil 60 }