Skip to content

Commit eb14887

Browse files
committed
Add help command
1 parent d564525 commit eb14887

File tree

2 files changed

+69
-2
lines changed

2 files changed

+69
-2
lines changed

cli/cmd/help.go

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,64 @@
11
package cmd
22

3-
//TODO
3+
import (
4+
"fmt"
5+
)
6+
7+
func PrintHelp() {
8+
9+
fmt.Println("\033[1m+------------------------+\033[0m")
10+
fmt.Println("\033[1m| UptimeKuma - Probe CLI |\033[0m")
11+
fmt.Println("\033[1m+------------------------+\033[0m")
12+
13+
fmt.Println("\033[1mRepository:\033[0m github.com/K-cermak/UptimeKumaProbe")
14+
fmt.Println("\033[1mLicense:\033[0m MIT")
15+
fmt.Println("\033[1mAuthor:\033[0m Karel Cermak | karlosoft.com")
16+
fmt.Println("\033[1mVersion:\033[0m v1.0, © 2025")
17+
18+
fmt.Println("\n\033[1mUsage: kprobe <command>\033[0m")
19+
fmt.Println("\n\033[1mCommands:\033[0m")
20+
21+
fmt.Println(" \033[1m-> cron <type>\033[0m")
22+
fmt.Println(" \033[3mStart the cron job with the specified type.\033[0m")
23+
fmt.Println(" \033[3mUse 'all' to start all cron jobs.\033[0m")
24+
fmt.Println(" \033[3mUse 'all_except:<names>' to start all cron jobs except the specified ones (seperate names with comma without space).\033[0m")
25+
fmt.Println(" \033[3mUse 'only:<names>' to start only the specified cron jobs (seperate names with comma without space).\033[0m")
26+
27+
fmt.Println("\n \033[1m-> history <scan_name> <from> <to>\033[0m")
28+
fmt.Println(" \033[3mView the history of the specified scan.\033[0m")
29+
fmt.Println(" \033[3mFor <from> and <to> use the format 'YYYY-MM-DD HH:MM:SS'.\033[0m")
30+
31+
fmt.Println("\n \033[1m-> db init\033[0m")
32+
fmt.Println(" \033[3mInitialize the database.\033[0m")
33+
fmt.Println(" \033[1m-> db reset\033[0m")
34+
fmt.Println(" \033[3mReset the database, this will delete all the data!\033[0m")
35+
36+
fmt.Println("\n \033[1m-> config verify <path>\033[0m")
37+
fmt.Println(" \033[3mVerify the configuration file at the specified path.\033[0m")
38+
fmt.Println(" \033[1m-> config replace <path>\033[0m")
39+
fmt.Println(" \033[3mReplace the current configuration with the one at the specified path.\033[0m")
40+
fmt.Println(" \033[3mFile is copied to the database, so you can delete the original file afterwards.\033[0m")
41+
fmt.Println(" \033[1m-> config view\033[0m")
42+
fmt.Println(" \033[3mView the current configuration.\033[0m")
43+
44+
fmt.Println("\n \033[1m-> keys view all\033[0m")
45+
fmt.Println(" \033[3mView all the keys with their values in the database.\033[0m")
46+
fmt.Println(" \033[3mKeys with the * prefix can be changed.\033[0m")
47+
fmt.Println(" \033[1m-> keys view <key>\033[0m")
48+
fmt.Println(" \033[3mView the value of the specified key.\033[0m")
49+
fmt.Println(" \033[3mIf the key has the * prefix, it can be changed.\033[0m")
50+
51+
fmt.Println("\n \033[1m-> test ping <address> <timeout_ms>\033[0m")
52+
fmt.Println(" \033[3mTest the ping to the specified address with the specified timeout.\033[0m")
53+
fmt.Println(" \033[3mTimeout is in milliseconds.\033[0m")
54+
fmt.Println(" \033[1m-> test http <address> <timeout_ms>\033[0m")
55+
fmt.Println(" \033[3mTest the http request to the specified address with the specified timeout.\033[0m")
56+
fmt.Println(" \033[3mTimeout is in milliseconds.\033[0m")
57+
fmt.Println(" \033[1m-> test api [service|http]\033[0m")
58+
fmt.Println(" \033[3mTest the api service or the http service.\033[0m")
59+
fmt.Println(" \033[3mUse 'service' to test the api service via systemctl.\033[0m")
60+
fmt.Println(" \033[3mUse 'http' to test the api service via http request.\033[0m")
61+
62+
fmt.Println("\n \033[1m-> help\033[0m")
63+
fmt.Println(" \033[3mPrint this help message.\033[0m")
64+
}

cli/main.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,17 @@ func main() {
7676
return
7777
}
7878

79-
//test api <service/http>
79+
//test api [service|http]
8080
if helpers.ArgsMatch(args, []string{"*", "test", "api", "*"}) {
8181
cmd.ApiTest(args[3])
8282
return
8383
}
8484

85+
//help
86+
if helpers.ArgsMatch(args, []string{"*", "help"}) {
87+
cmd.PrintHelp()
88+
return
89+
}
90+
8591
helpers.PrintError(true, "Invalid command, rerun with <kprobe help> for help")
8692
}

0 commit comments

Comments
 (0)