Skip to content

Commit

Permalink
Add help command
Browse files Browse the repository at this point in the history
  • Loading branch information
K-cermak committed Feb 1, 2025
1 parent d564525 commit eb14887
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 2 deletions.
63 changes: 62 additions & 1 deletion cli/cmd/help.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,64 @@
package cmd

//TODO
import (
"fmt"
)

func PrintHelp() {

fmt.Println("\033[1m+------------------------+\033[0m")
fmt.Println("\033[1m| UptimeKuma - Probe CLI |\033[0m")
fmt.Println("\033[1m+------------------------+\033[0m")

fmt.Println("\033[1mRepository:\033[0m github.com/K-cermak/UptimeKumaProbe")
fmt.Println("\033[1mLicense:\033[0m MIT")
fmt.Println("\033[1mAuthor:\033[0m Karel Cermak | karlosoft.com")
fmt.Println("\033[1mVersion:\033[0m v1.0, © 2025")

fmt.Println("\n\033[1mUsage: kprobe <command>\033[0m")
fmt.Println("\n\033[1mCommands:\033[0m")

fmt.Println(" \033[1m-> cron <type>\033[0m")
fmt.Println(" \033[3mStart the cron job with the specified type.\033[0m")
fmt.Println(" \033[3mUse 'all' to start all cron jobs.\033[0m")
fmt.Println(" \033[3mUse 'all_except:<names>' to start all cron jobs except the specified ones (seperate names with comma without space).\033[0m")
fmt.Println(" \033[3mUse 'only:<names>' to start only the specified cron jobs (seperate names with comma without space).\033[0m")

fmt.Println("\n \033[1m-> history <scan_name> <from> <to>\033[0m")
fmt.Println(" \033[3mView the history of the specified scan.\033[0m")
fmt.Println(" \033[3mFor <from> and <to> use the format 'YYYY-MM-DD HH:MM:SS'.\033[0m")

fmt.Println("\n \033[1m-> db init\033[0m")
fmt.Println(" \033[3mInitialize the database.\033[0m")
fmt.Println(" \033[1m-> db reset\033[0m")
fmt.Println(" \033[3mReset the database, this will delete all the data!\033[0m")

fmt.Println("\n \033[1m-> config verify <path>\033[0m")
fmt.Println(" \033[3mVerify the configuration file at the specified path.\033[0m")
fmt.Println(" \033[1m-> config replace <path>\033[0m")
fmt.Println(" \033[3mReplace the current configuration with the one at the specified path.\033[0m")
fmt.Println(" \033[3mFile is copied to the database, so you can delete the original file afterwards.\033[0m")
fmt.Println(" \033[1m-> config view\033[0m")
fmt.Println(" \033[3mView the current configuration.\033[0m")

fmt.Println("\n \033[1m-> keys view all\033[0m")
fmt.Println(" \033[3mView all the keys with their values in the database.\033[0m")
fmt.Println(" \033[3mKeys with the * prefix can be changed.\033[0m")
fmt.Println(" \033[1m-> keys view <key>\033[0m")
fmt.Println(" \033[3mView the value of the specified key.\033[0m")
fmt.Println(" \033[3mIf the key has the * prefix, it can be changed.\033[0m")

fmt.Println("\n \033[1m-> test ping <address> <timeout_ms>\033[0m")
fmt.Println(" \033[3mTest the ping to the specified address with the specified timeout.\033[0m")
fmt.Println(" \033[3mTimeout is in milliseconds.\033[0m")
fmt.Println(" \033[1m-> test http <address> <timeout_ms>\033[0m")
fmt.Println(" \033[3mTest the http request to the specified address with the specified timeout.\033[0m")
fmt.Println(" \033[3mTimeout is in milliseconds.\033[0m")
fmt.Println(" \033[1m-> test api [service|http]\033[0m")
fmt.Println(" \033[3mTest the api service or the http service.\033[0m")
fmt.Println(" \033[3mUse 'service' to test the api service via systemctl.\033[0m")
fmt.Println(" \033[3mUse 'http' to test the api service via http request.\033[0m")

fmt.Println("\n \033[1m-> help\033[0m")
fmt.Println(" \033[3mPrint this help message.\033[0m")
}
8 changes: 7 additions & 1 deletion cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,17 @@ func main() {
return
}

//test api <service/http>
//test api [service|http]
if helpers.ArgsMatch(args, []string{"*", "test", "api", "*"}) {
cmd.ApiTest(args[3])
return
}

//help
if helpers.ArgsMatch(args, []string{"*", "help"}) {
cmd.PrintHelp()
return
}

helpers.PrintError(true, "Invalid command, rerun with <kprobe help> for help")
}

0 comments on commit eb14887

Please sign in to comment.