1 Star 1 Fork 5

infraboard / go-share-examples

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
root.go 1.24 KB
一键复制 编辑 原始数据 按行查看 历史
Mr.Yu 提交于 2021-12-19 09:42 . 更新 sk
package cmd
import (
"errors"
"fmt"
"os"
"github.com/spf13/cobra"
)
var (
ossProvider string
vers bool
ossEndpoint string
aliAccessID string
aliSecretKey string
)
// RootCmd represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
Use: "cloud-station-cli",
Short: "cloud-station-cli 文件中转服务",
Long: `cloud-station-cli ...`,
RunE: func(cmd *cobra.Command, args []string) error {
if vers {
fmt.Println("0.0.1")
return nil
}
return errors.New("no flags find")
},
}
// Execute adds all child commands to the root command sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
if err := RootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
func init() {
// -i, --ali_access_id
RootCmd.PersistentFlags().StringVarP(&ossProvider, "provider", "p", "aliyun", "the oss provider [ali/tx/aws]")
RootCmd.PersistentFlags().StringVarP(&ossEndpoint, "oss_endpoint", "e", "", "oss service endpint")
RootCmd.PersistentFlags().StringVarP(&aliAccessID, "ali_access_id", "i", "", "the ali oss access id")
RootCmd.PersistentFlags().BoolVarP(&vers, "version", "v", false, "the cloud-station-cli version")
}
Go
1
https://gitee.com/infraboard/go-share-examples.git
git@gitee.com:infraboard/go-share-examples.git
infraboard
go-share-examples
go-share-examples
f243a2248fe7

搜索帮助