/
cmd.go
90 lines (86 loc) · 1.67 KB
/
cmd.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package main
import "github.com/spf13/cobra"
var rootCmd = &cobra.Command{
Use: "tinyfeed [FEED_URL ...]",
Short: "Aggregate a collection of feed into static HTML page",
Long: "Aggregate a collection of feed into static HTML page. Only RSS, Atom and JSON feeds are supported.",
Example: ` single feed tinyfeed lovergne.dev/rss.xml > index.html
multiple feeds cat feeds.txt | tinyfeed > index.html`,
Args: cobra.ArbitraryArgs,
RunE: tinyfeed,
SilenceUsage: true,
}
// flags
var limit int
var timeout int
var requestSemaphore int
var name string
var description string
var imageAllowed bool
var quiet bool
var stylesheet string
var templatePath string
func init() {
rootCmd.Flags().IntVarP(
&limit,
"limit",
"l",
50,
"How many articles to display",
)
rootCmd.Flags().IntVarP(
&requestSemaphore,
"requests",
"r",
8,
"How many simulaneous requests can be made",
)
rootCmd.Flags().IntVar(
&timeout,
"timeout",
15,
"timeout to get feeds in seconds",
)
rootCmd.Flags().StringVarP(
&name,
"name",
"n",
"Feed",
"Title of the page.",
)
rootCmd.Flags().StringVarP(
&description,
"description",
"d",
"",
"Add a description after the name of your page",
)
rootCmd.Flags().BoolVarP(
&imageAllowed,
"images",
"i",
false,
"Add this flag to load images in summaries",
)
rootCmd.Flags().BoolVarP(
&quiet,
"quiet",
"q",
false,
"Add this flag to silence warnings.",
)
rootCmd.Flags().StringVarP(
&stylesheet,
"stylesheet",
"s",
"",
"Path to an external CSS stylesheet",
)
rootCmd.Flags().StringVarP(
&templatePath,
"template",
"t",
"",
"Path to a custom HTML+Go template file.",
)
}