[#1074] neofs-cli: Move common API flags to a separate package

TTL and XHeader flags are reused between multiple commands.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-05-30 16:04:40 +03:00 committed by fyrchik
parent 736e09a70d
commit a2bcb3e0ce
6 changed files with 45 additions and 41 deletions

View file

@ -57,7 +57,7 @@ var (
// bind exactly that cmd's flags to
// the viper before execution
commonflags.Bind(cmd)
bindAPIFlags(cmd)
commonflags.BindAPI(cmd)
},
}
@ -270,8 +270,7 @@ func init() {
flags := objCommand.Flags()
flags.String(bearerTokenFlag, "", "File with signed JSON or binary encoded bearer token")
flags.StringSliceVarP(&xHeaders, xHeadersKey, xHeadersShorthand, xHeadersDefault, xHeadersUsage)
flags.Uint32P(ttl, ttlShorthand, ttlDefault, ttlUsage)
commonflags.InitAPI(objCommand)
}
// Here you will define your flags and configuration settings.
@ -398,7 +397,7 @@ func prepareObjectPrm(cmd *cobra.Command, prms ...objectPrm) {
prepareBearerPrm(cmd, prms[i])
prms[i].SetTTL(getTTL())
prms[i].SetXHeaders(parseXHeaders())
prms[i].SetXHeaders(parseXHeaders(cmd))
}
}