[#1402] cli: Add cid
flag constant
Also, move common flag constants in `root` file of the `storagegroup` package. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
6f2363cf31
commit
bc5882fc89
6 changed files with 16 additions and 17 deletions
|
@ -24,8 +24,8 @@ func initSGDeleteCmd() {
|
|||
|
||||
flags := sgDelCmd.Flags()
|
||||
|
||||
flags.String("cid", "", "Container ID")
|
||||
_ = sgDelCmd.MarkFlagRequired("cid")
|
||||
flags.String(cidFlag, "", "Container ID")
|
||||
_ = sgDelCmd.MarkFlagRequired(cidFlag)
|
||||
|
||||
flags.StringVarP(&sgID, sgIDFlag, "", "", "storage group identifier")
|
||||
_ = sgDelCmd.MarkFlagRequired(sgIDFlag)
|
||||
|
|
|
@ -15,11 +15,6 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const (
|
||||
sgIDFlag = "id"
|
||||
sgRawFlag = "raw"
|
||||
)
|
||||
|
||||
var sgID string
|
||||
|
||||
var sgGetCmd = &cobra.Command{
|
||||
|
@ -34,8 +29,8 @@ func initSGGetCmd() {
|
|||
|
||||
flags := sgGetCmd.Flags()
|
||||
|
||||
flags.String("cid", "", "Container ID")
|
||||
_ = sgGetCmd.MarkFlagRequired("cid")
|
||||
flags.String(cidFlag, "", "Container ID")
|
||||
_ = sgGetCmd.MarkFlagRequired(cidFlag)
|
||||
|
||||
flags.StringVarP(&sgID, sgIDFlag, "", "", "storage group identifier")
|
||||
_ = sgGetCmd.MarkFlagRequired(sgIDFlag)
|
||||
|
|
|
@ -22,8 +22,8 @@ var sgListCmd = &cobra.Command{
|
|||
func initSGListCmd() {
|
||||
commonflags.Init(sgListCmd)
|
||||
|
||||
sgListCmd.Flags().String("cid", "", "Container ID")
|
||||
_ = sgListCmd.MarkFlagRequired("cid")
|
||||
sgListCmd.Flags().String(cidFlag, "", "Container ID")
|
||||
_ = sgListCmd.MarkFlagRequired(cidFlag)
|
||||
}
|
||||
|
||||
func listSG(cmd *cobra.Command, _ []string) {
|
||||
|
|
|
@ -36,8 +36,8 @@ func initSGPutCmd() {
|
|||
|
||||
flags := sgPutCmd.Flags()
|
||||
|
||||
flags.String("cid", "", "Container ID")
|
||||
_ = sgPutCmd.MarkFlagRequired("cid")
|
||||
flags.String(cidFlag, "", "Container ID")
|
||||
_ = sgPutCmd.MarkFlagRequired(cidFlag)
|
||||
|
||||
flags.StringSliceVarP(&sgMembers, sgMembersFlag, "m", nil, "ID list of storage group members")
|
||||
_ = sgPutCmd.MarkFlagRequired(sgMembersFlag)
|
||||
|
|
|
@ -19,6 +19,12 @@ var Cmd = &cobra.Command{
|
|||
},
|
||||
}
|
||||
|
||||
const (
|
||||
sgIDFlag = "id"
|
||||
sgRawFlag = "raw"
|
||||
cidFlag = "cid"
|
||||
)
|
||||
|
||||
func init() {
|
||||
storageGroupChildCommands := []*cobra.Command{
|
||||
sgPutCmd,
|
||||
|
|
|
@ -20,11 +20,9 @@ func readObjectAddress(cmd *cobra.Command, cnr *cid.ID, obj *oid.ID) oid.Address
|
|||
}
|
||||
|
||||
func readCID(cmd *cobra.Command, id *cid.ID) {
|
||||
const flag = "cid"
|
||||
|
||||
f := cmd.Flag(flag)
|
||||
f := cmd.Flag(cidFlag)
|
||||
if f == nil {
|
||||
common.ExitOnErr(cmd, "", fmt.Errorf("missing container flag (%s)", flag))
|
||||
common.ExitOnErr(cmd, "", fmt.Errorf("missing container flag (%s)", cidFlag))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue