in commands/activation.go [268:296]
func lastFlag(args []string) ([]string, error) {
if Flags.activation.last {
options := &whisk.ActivationListOptions{
Limit: 1,
Skip: 0,
}
activations, _, err := Client.Activations.List(options)
if err != nil { // Checks Activations.List for errors when retrieving latest activation
whisk.Debug(whisk.DbgError, "Client.Activations.List(%#v) error during lastFlag: %s\n", options, err)
return args, err
}
if len(activations) == 0 { // Checks to see if there are activations available
whisk.Debug(whisk.DbgError, "No activations found in activation list\n")
errStr := wski18n.T("Activation list does not contain any activations.")
whiskErr := whisk.MakeWskError(errors.New(errStr), whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.DISPLAY_USAGE)
return args, whiskErr
}
if len(args) == 0 {
whisk.Debug(whisk.DbgInfo, "Appending most recent activation ID(%s) into args\n", activations[0].ActivationID)
args = append(args, activations[0].ActivationID)
} else {
whisk.Debug(whisk.DbgInfo, "Appending most recent activation ID(%s) into args\n", activations[0].ActivationID)
args = append(args, activations[0].ActivationID)
whisk.Debug(whisk.DbgInfo, "Allocating appended ID to correct position in args\n")
args[0], args[len(args)-1] = args[len(args)-1], args[0] // IDs should be located at args[0], if 1 or more arguments are given ID has to be moved to args[0]
}
}
return args, nil
}