mirror of
https://github.com/wonli/aqi.git
synced 2025-12-24 10:40:58 +08:00
38 lines
744 B
Cheetah
38 lines
744 B
Cheetah
package cmd
|
||
|
||
import (
|
||
"fmt"
|
||
"os"
|
||
"path/filepath"
|
||
"strings"
|
||
_ "time/tzdata"
|
||
|
||
"github.com/spf13/cobra"
|
||
)
|
||
|
||
var timezone string
|
||
var configFile string
|
||
|
||
func init() {
|
||
rootCmd.PersistentFlags().StringVarP(&timezone, "tz", "t", "default", "指定时区")
|
||
rootCmd.PersistentFlags().StringVarP(&configFile, "config", "c", "config.yaml", "指定配置文件路径,默认当前路径下config.yaml")
|
||
cobra.OnInitialize(func() {
|
||
})
|
||
}
|
||
|
||
var runApp = filepath.Base(strings.TrimLeft(os.Args[0], "./"))
|
||
var rootCmd = &cobra.Command{
|
||
Use: runApp,
|
||
Version: "{{.PackageName}}",
|
||
Run: func(cmd *cobra.Command, args []string) {
|
||
_ = cmd.Help()
|
||
},
|
||
}
|
||
|
||
func Execute() {
|
||
if err := rootCmd.Execute(); err != nil {
|
||
fmt.Println(err)
|
||
os.Exit(1)
|
||
}
|
||
}
|