// Init implements Command.Init.
345123
func (c *importKeysCommand) Init(args []string) error {
	if len(args) == 0 {
		return errors.New("no ssh key id specified")
	}
	c.sshKeyIds = args
	for _, k := range c.sshKeyIds {
		if len(k) < 3 {
			return errors.NotValidf("%q key ID", k)
		}
		switch k[:3] {
		case "lp:", "gh:":
		default:
			return errors.NewNotSupported(nil,
				fmt.Sprintf("prefix in Key ID %q not supported, only lp: and gh: are allowed", k))
		}
	}
	return nil
}
848160
func (c *leaderGetCommand) Init(args []string) error {
	c.key = ""
	if len(args) == 0 {
		return nil
	}
	key := args[0]
	if key == "-" {
		key = ""
	} else if strings.Contains(key, "=") {
		return errors.Errorf("invalid key %q", key)
	}
	c.key = key
	return cmd.CheckEmpty(args[1:])
}
1188747
func (c *findCommand) Init(args []string) (err error) {
	if c.offerName != "" && c.url != "" {
		return errors.New("cannot specify both a URL term and offer term")
	}
	url, err := cmd.ZeroOrOneArgs(args)
	if err != nil {
		return errors.Trace(err)
	}
	if url != "" {
		if c.url != "" {
			return errors.New("URL term cannot be specified twice")
		}
		c.url = url
	}
	return nil
}
713794
func (c *removeCommand) Init(args []string) (err error) {
	if c.Kind == "" {
		return errors.New("image kind must be specified")
	}
	if c.Series == "" {
		return errors.New("image series must be specified")
	}
	if c.Arch == "" {
		return errors.New("image architecture must be specified")
	}
	return cmd.CheckEmpty(args)
}
78513
func (c *createCommand) Init(args []string) error {
	// If user specifies that a download is not desired (i.e. no-download == true),
	// and they have EXPLICITLY not wanted to store a remote backup file copy
	// (i.e keep-copy == false), then there is no point for us to proceed as
	// all the backup will not be stored anywhere.
	if c.NoDownload {
		keepCopySet := false
		c.fs.Visit(func(flag *gnuflag.Flag) {
			if flag.Name == "keep-copy" {
				keepCopySet = true
			}
		})
		if keepCopySet && !c.KeepCopy {
			return errors.Errorf("--no-download cannot be set when --keep-copy is not: the backup will not be created")
		}
	}
	notes, err := cmd.ZeroOrOneArgs(args)
	if err != nil {
		return err
	}
	c.Notes = notes

	if c.Filename != notset && c.NoDownload {
		return errors.Errorf("cannot mix --no-download and --filename")
	}

	if c.Filename == "" {
		return errors.Errorf("missing filename")
	}
	return nil
}
1126532
func (c *enableCommand) Init(args []string) error {
	if len(args) < 1 {
		return errors.Errorf("missing command set (%s)", validTargets)
	}
	c.target, args = args[0], args[1:]
	target, ok := toAPIValue[c.target]
	if !ok {
		return errors.Errorf("bad command set, valid options: %s", validTargets)
	}
	c.target = target
	return cmd.CheckEmpty(args)
}
1360029
func (c *UploadCommand) Init(args []string) error {
	switch len(args) {
	case 0:
		return errors.BadRequestf("missing application name")
	case 1:
		return errors.BadRequestf("no resource specified")
	}

	c.application = args[0]
	if !names.IsValidApplication(c.application) {
		return errors.NotValidf("application %q", c.application)
	}

	if err := c.addResourceValue(args[1]); err != nil {
		return errors.Trace(err)
	}
	return cmd.CheckEmpty(args[2:])
}
266128
func (c *restoreCommand) Init(args []string) error {
	if c.Filename == "" && c.BackupId == "" {
		return errors.Errorf("you must specify either a file or a backup id.")
	}
	if c.Filename != "" && c.BackupId != "" {
		return errors.Errorf("you must specify either a file or a backup id but not both.")
	}

	if c.Filename != "" {
		var err error
		c.Filename, err = filepath.Abs(c.Filename)
		if err != nil {
			return errors.Trace(err)
		}
	}

	return nil
}
1129604
func (c *RemoveCommand) Init(args []string) error {
	// Ensure we have exactly 1 argument.
	err := c.CheckNumArgs(args, []error{errNoCIDR})
	if err != nil {
		return err
	}

	// Validate given CIDR.
	c.CIDR, err = c.ValidateCIDR(args[0], true)
	if err != nil {
		return err
	}

	return cmd.CheckEmpty(args[1:])
}
1120652
func (c *listCommand) Init(args []string) (err error) {
	c.modelName, err = cmd.ZeroOrOneArgs(args)
	if err != nil {
		return err
	}
	return err
}
1046138
func (c *showOutputCommand) Init(args []string) error {
	switch len(args) {
	case 0:
		return errors.New("no action ID specified")
	case 1:
		c.requestedId = args[0]
		return nil
	default:
		return cmd.CheckEmpty(args[1:])
	}
}
1129552
func (c *AddCommand) Init(args []string) error {
	var err error
	c.Name, c.CIDRs, err = ParseNameAndCIDRs(args, true)
	return err
}
737248
func (c *disableCommand) Init(args []string) error {
	if len(args) < 1 {
		return errors.Errorf("missing command set (%s)", validTargets)
	}
	c.target, args = args[0], args[1:]
	target, ok := toAPIValue[c.target]
	if !ok {
		return errors.Errorf("bad command set, valid options: %s", validTargets)
	}
	c.target = target
	c.message = strings.Join(args, " ")
	return nil
}
455618
func (c *listCommand) Init(args []string) (err error) {
	offerName, err := cmd.ZeroOrOneArgs(args)
	if err != nil {
		return errors.Trace(err)
	}
	c.offerName = offerName
	return nil
}
236571
func Init(c *config.Config) (*Service, error) {
	return &Service{Config: c}, nil
}
609300
func (c *checkoutCommand) Init(args []string) error {
	if len(args) != 1 {
		return errors.Errorf("must specify a branch name to switch to")
	}
	c.branchName = args[0]
	return nil
}
609018
func (c *GetCmd) Init(args []string) error {
	if len(args) < 1 {
		return errors.Errorf("missing required resource name")
	} else if err := cmd.CheckEmpty(args[1:]); err != nil {
		return errors.Trace(err)
	}
	c.resourceName = args[0]
	return nil
}