-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
47 lines (41 loc) · 1.25 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"github.com/spf13/cobra"
"log"
)
var rootCmd = &cobra.Command{
Use: "float",
Short: "CSFloat price check",
Long: `A CSFloat price checker CLI`,
Run: run,
}
func init() {
rootCmd.Flags().Bool("cron", false, "Enable cron mode")
rootCmd.Flags().BoolP("auctions", "a", false, "Also check auctions")
rootCmd.Flags().IntP("max", "m", 0, "Max price in cents")
rootCmd.Flags().IntP("min", "n", 0, "Min price in cents")
rootCmd.Flags().Float64P("discount", "d", 5.00, "Min discount percentage")
rootCmd.Flags().IntP("category", "c", 1, "Item category - [0: Any, 1: Normal, 2: Stattrak, 3: Souvenir]")
rootCmd.Flags().BoolP("stickers", "s", false, "Show stickers? (Default off)")
rootCmd.Flags().IntP("top", "t", 10, "Top List")
rootCmd.Flags().StringP("keyfile", "f", "", "The location of your API key file")
rootCmd.Flags().StringP("keyword", "k", "", "The keyword. e.g a Skin Name like 'Asiimov' or 'Dragon Lore'")
}
func main() {
err := rootCmd.Execute()
if err != nil {
log.Default().Fatal(err)
}
}
func run(cmd *cobra.Command, _ []string) {
flags, err := ParseFlags(cmd.Flags())
if err != nil {
log.Default().Fatal(err)
}
if flags.Cron {
c := make(chan string)
RunCronSchedule(flags, c)
<-c
}
FindSkins(flags)
}