refactor: cmd update.

This commit is contained in:
Gordon 2024-04-12 17:30:57 +08:00
parent 76abe4948f
commit 1890174565
2 changed files with 1 additions and 3 deletions

View File

@ -46,7 +46,7 @@ func NewPushRpcCmd() *PushRpcCmd {
} }
ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap)) ret.RootCmd = NewRootCmd(program.GetProcessName(), WithConfigMap(ret.configMap))
ret.ctx = context.WithValue(context.Background(), "version", config.Version) ret.ctx = context.WithValue(context.Background(), "version", config.Version)
ret.Command.RunE = func(cmd *cobra.Command, args []string) error { ret.Command.PreRunE = func(cmd *cobra.Command, args []string) error {
return ret.preRunE() return ret.preRunE()
} }
return ret return ret

View File

@ -152,12 +152,10 @@ func defaultCmdOpts() *CmdOpts {
func (r *RootCmd) getFlag(cmd *cobra.Command) (string, int, error) { func (r *RootCmd) getFlag(cmd *cobra.Command) (string, int, error) {
configDirectory, err := cmd.Flags().GetString(FlagConf) configDirectory, err := cmd.Flags().GetString(FlagConf)
if err != nil { if err != nil {
fmt.Println("err info ", err)
return "", 0, errs.Wrap(err) return "", 0, errs.Wrap(err)
} }
index, err := cmd.Flags().GetInt(FlagTransferIndex) index, err := cmd.Flags().GetInt(FlagTransferIndex)
if err != nil { if err != nil {
fmt.Println("err info ", err)
return "", 0, errs.Wrap(err) return "", 0, errs.Wrap(err)
} }
r.index = index r.index = index