github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/cmd/juju/machine/show.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  
     9  	jujucmd "github.com/juju/juju/cmd"
    10  	"github.com/juju/juju/cmd/modelcmd"
    11  )
    12  
    13  const showMachineCommandDoc = `
    14  Show a specified machine on a model.  Default format is in yaml,
    15  other formats can be specified with the "--format" option.
    16  Available formats are yaml, tabular, and json
    17  
    18  Examples:
    19      # Display status for machine 0
    20      juju show-machine 0
    21  
    22      # Display status for machines 1, 2 & 3
    23      juju show-machine 1 2 3
    24  
    25  `
    26  
    27  // NewShowMachineCommand returns a command that shows details on the specified machine[s].
    28  func NewShowMachineCommand() cmd.Command {
    29  	return modelcmd.Wrap(newShowMachineCommand(nil))
    30  }
    31  
    32  func newShowMachineCommand(api statusAPI) *showMachineCommand {
    33  	showCmd := &showMachineCommand{}
    34  	showCmd.defaultFormat = "yaml"
    35  	showCmd.api = api
    36  	return showCmd
    37  }
    38  
    39  // showMachineCommand struct holds details on the specified machine[s].
    40  type showMachineCommand struct {
    41  	baselistMachinesCommand
    42  }
    43  
    44  // Info implements Command.Info.
    45  func (c *showMachineCommand) Info() *cmd.Info {
    46  	return jujucmd.Info(&cmd.Info{
    47  		Name:    "show-machine",
    48  		Args:    "<machineID> ...",
    49  		Purpose: "Show a machine's status.",
    50  		Doc:     showMachineCommandDoc,
    51  	})
    52  }
    53  
    54  // Init captures machineId's to show from CL args.
    55  func (c *showMachineCommand) Init(args []string) error {
    56  	c.machineIds = args
    57  	return nil
    58  }