Print out help message.
Print our help message when run with no argument's or --help|-h.
This commit is contained in:
parent
ae83c11649
commit
a5a58dfd32
33
main.go
33
main.go
@ -10,6 +10,21 @@ import (
|
||||
miniflux "miniflux.app/client"
|
||||
)
|
||||
|
||||
// Help message
|
||||
const HELP = `examples:
|
||||
mfeed create {category_id} {feed_url}
|
||||
|
||||
usage: mfeed [-h] {feeds,categories,create} ...
|
||||
feeds list all the feeds you have
|
||||
categories list all the categories you have
|
||||
create create a new feed
|
||||
|
||||
positional arguments:
|
||||
{feeds, categories, create}
|
||||
|
||||
options:
|
||||
-h, --help shows this help page`
|
||||
|
||||
// Crreate the config struct
|
||||
type Configuration struct {
|
||||
Instance string
|
||||
@ -18,6 +33,18 @@ type Configuration struct {
|
||||
}
|
||||
|
||||
func main() {
|
||||
// print help message based on first argument
|
||||
if len(os.Args) < 2 {
|
||||
fmt.Println(HELP)
|
||||
return
|
||||
} else if os.Args[1] == "-h" {
|
||||
fmt.Println(HELP)
|
||||
return
|
||||
} else if os.Args[1] == "--help" {
|
||||
fmt.Println(HELP)
|
||||
return
|
||||
}
|
||||
|
||||
// get config folder locaation
|
||||
config_dir, _ := os.UserConfigDir()
|
||||
|
||||
@ -51,12 +78,6 @@ func main() {
|
||||
string(pass),
|
||||
)
|
||||
|
||||
// check if atleast one option is provided
|
||||
if len(os.Args) < 2 {
|
||||
fmt.Println("No option provided!")
|
||||
return
|
||||
}
|
||||
|
||||
// Run fuction based on first argument
|
||||
switch os.Args[1] {
|
||||
case "feeds":
|
||||
|
Loading…
Reference in New Issue
Block a user