Skip to content

Commit

Permalink
chore(cmd): comments of commands. close #7
Browse files Browse the repository at this point in the history
  • Loading branch information
iyear committed Jul 30, 2022
1 parent 48a9db8 commit 6ad2558
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
7 changes: 3 additions & 4 deletions cmd/query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ var (

var Cmd = &cobra.Command{
Use: "query",
Short: "",
Long: ``,
Short: "Query messages",
Run: func(cmd *cobra.Command, args []string) {
if err := query.Query(searchDriver, searchOptions, _query, pn, ps, json); err != nil {
color.Red("error happens: %v", err)
Expand All @@ -28,8 +27,8 @@ var Cmd = &cobra.Command{
}

func init() {
Cmd.PersistentFlags().StringVarP(&searchDriver, "driver", "d", "", "search driver used")
Cmd.PersistentFlags().StringToStringVarP(&searchOptions, "options", "o", make(map[string]string), "options for search driver")
Cmd.PersistentFlags().StringVarP(&searchDriver, "driver", "d", "", "used search engine driver")
Cmd.PersistentFlags().StringToStringVarP(&searchOptions, "options", "o", make(map[string]string), "search engine options")
Cmd.PersistentFlags().StringVarP(&_query, "query", "q", "", "query keyword or statement")
Cmd.PersistentFlags().IntVar(&pn, "pn", 0, "page number, starting from 0")
Cmd.PersistentFlags().IntVar(&ps, "ps", 10, "page size")
Expand Down
3 changes: 1 addition & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import (
// TODO
var cmd = &cobra.Command{
Use: "searchx",
Short: "",
Long: ``,
Short: "Enhance Telegram Group/Channel Search In 5 Minutes",
}

func init() {
Expand Down
5 changes: 2 additions & 3 deletions cmd/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ var (

var Cmd = &cobra.Command{
Use: "run",
Short: "Start the bot",
Long: `Start the bot`,
Short: "Run the bot",
Run: func(cmd *cobra.Command, args []string) {
bot.Run(cfg)
},
}

func init() {
Cmd.PersistentFlags().StringVarP(&cfg, "config", "c", "config/config.yaml", "bot config file")
Cmd.PersistentFlags().StringVarP(&cfg, "config", "c", "config/config.yaml", "the path to the config file")
}
9 changes: 4 additions & 5 deletions cmd/source/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ var (

var Cmd = &cobra.Command{
Use: "source",
Short: "",
Long: ``,
Short: "Import history messages",
Run: func(cmd *cobra.Command, args []string) {
if err := source.Start(src, searchDriver, searchOptions); err != nil {
color.Red("error happens: %v", err)
Expand All @@ -25,7 +24,7 @@ var Cmd = &cobra.Command{
}

func init() {
Cmd.PersistentFlags().StringVarP(&src, "file", "f", "result.json", "The path to the JSON file exported by Telegram")
Cmd.PersistentFlags().StringVarP(&searchDriver, "driver", "d", "", "Used search driver")
Cmd.PersistentFlags().StringToStringVarP(&searchOptions, "options", "o", make(map[string]string), "")
Cmd.PersistentFlags().StringVarP(&src, "file", "f", "result.json", "the path to the JSON file exported by Telegram")
Cmd.PersistentFlags().StringVarP(&searchDriver, "driver", "d", "", "used search engine driver")
Cmd.PersistentFlags().StringToStringVarP(&searchOptions, "options", "o", make(map[string]string), "search engine options")
}
3 changes: 1 addition & 2 deletions cmd/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ var version string

var Cmd = &cobra.Command{
Use: "version",
Short: "",
Long: ``,
Short: "Check the version info",
Run: func(cmd *cobra.Command, args []string) {
buf := &bytes.Buffer{}
_ = template.Must(template.New("version").Parse(version)).Execute(buf, map[string]interface{}{
Expand Down

0 comments on commit 6ad2558

Please sign in to comment.