// 2019 Rackspace, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"): you may // not use this file except in compliance with the License. You may obtain // a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the // License for the specific language governing permissions and limitations // under the License. // Package shared is a specific gomigrate package used to aggregate functions that are // helpful and can be used across multiple plugins. package shared import ( "strings" "github.com/jokelyo/argparse" ) // ArgMoveGroup function will return the values from a move-group argument passed into the parser func ArgMoveGroup(cmd *argparse.Command) *string { return cmd.String("m", "move-group", &argparse.Options{Help: "Move-Group name. E.g. ORD1-01-M01"}) } // ArgMoveGroups function will return the values from a move-groups argument passed into the parser func ArgMoveGroups(cmd *argparse.Command) *[]string { return cmd.Strings("m", "move-groups", &argparse.Options{Help: "list of move-groups. E.g. ORD1-01-M01 ORD1-01-M02", Nargs: "+"}) } // ArgDevices function will return the values from a devices argument passed into the parser func ArgDevices(cmd *argparse.Command, desc ...string) *[]int { help := "list of CORE device IDs. E.g. 879665 879666" if len(desc) != 0 { help = strings.Join(desc, ",") } return cmd.Ints("d", "devices", &argparse.Options{Help: help, Nargs: "+"}) } // ArgAccounts function will return the values from an accounts argument passed into the parser func ArgAccounts(cmd *argparse.Command, desc ...string) *[]string { help := "list of CORE accounts. E.g. 5002028 990037" if len(desc) != 0 { help = strings.Join(desc, ",") } return cmd.Strings("a", "accounts", &argparse.Options{Help: help, Nargs: "+"}) } // ArgEnvironment function will return the value from an environment argument passed into the parser func ArgEnvironment(cmd *argparse.Command) *string { return cmd.String("e", "env", &argparse.Options{Help: "Environment Number", Required: true}) } // ArgEnvironments function will return the values from an environments argument passed into the parser func ArgEnvironments(cmd *argparse.Command) *[]string { return cmd.Strings("e", "environments", &argparse.Options{Help: "list of EM environments. E.g. ENV11212 ENV56475", Nargs: "+"}) } // ArgFlag function will return the values from an environments argument passed into the parser func ArgFlag(cmd *argparse.Command, name, desc string) *bool { return cmd.Flag(name[0:1], name, &argparse.Options{Help: desc}) } // ArgUnipedeAge will return the in of a unipede age func ArgUnipedeAge(cmd *argparse.Command, def int) *int { return cmd.Int("", "age", &argparse.Options{Help: "Set unipede age in seconds", Default: def}, // Argument options ) } // ArgRoutines will return the in of a unipede age func ArgRoutines(cmd *argparse.Command, def int) *int { return cmd.Int("t", "threads", &argparse.Options{Help: "Number of concurrent processes to run", Default: def}, // Argument options ) }