Print out help message.

Print our help message when run with no argument's or --help|-h.
This commit is contained in:
CronyAkatsuki 2023-11-11 20:14:44 +01:00
parent ae83c11649
commit a5a58dfd32

33
main.go
View File

@ -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":