diff --git a/main.go b/main.go index 72890d6..8f4c2dc 100644 --- a/main.go +++ b/main.go @@ -64,8 +64,7 @@ func expandTilde(path string) string { } func displayUsage() { - fmt.Println("spacewalk [stuff] [things]") - os.Exit(0) + fmt.Println("spacewalk \033[3mcommand\033[23m [\033[3moptions...\033[23m]\n\nAvailable commands:\n\tcreate\n\tupdate\n\tremove\n\tdelete\n\tadd\n\tshow\n\tlaunch\n\thelp") } // parseArgs is the main entry point into scbm and will run the appropriate functions @@ -74,6 +73,7 @@ func parseArgs() { a := os.Args if len(a) == 1 { displayUsage() + os.Exit(0) } switch a[1] { @@ -123,8 +123,17 @@ func parseArgs() { } else { earlyExit("Incorrect syntax.\n- spacewalk show [\033[3mflight\033[0m]") } + case "help": + if len(a) == 2 { + displayHelp("") + } else if len(a) == 3 { + displayHelp(a[2]) + } else { + earlyExit("Incorrect syntax.\n- spacewalk help [\033[3mcommand\033[0m]") + } default: - earlyExit(fmt.Sprintf("Unknown command %q", a[1])) + displayUsage() + earlyExit(fmt.Sprintf("Unknown command %q.\nTry: `spacewalk help`", a[1])) } } @@ -344,6 +353,30 @@ func create(flight string) { ff.Close() } +func displayHelp(command string) { + switch command { + case "launch": + fmt.Println("Format: spacewalk launch [\033[3mflight\033[23m\n\nWhen run without a flight, spacewalk will launch all flights. When passed a flight it will just launch the given flight. A launch is defined as checking all of the remote pages for updates and generating a new version of the output file.") + case "create": + fmt.Println("Format: spacewalk create \033[3mflight\033[23m\n\nCreates a new flight with the given name. A flight can have capsules added to it, a header and footer assigned, and have it all launched to an output file.") + case "add": + fmt.Println("Format: spacewalk add \033[3mflight url title\033[23m\n\nAdds the given capsule url to the given flight. When the flight is launched, the given capsule will be named with the given title.") + case "remove": + fmt.Println("Format: spacewalk remove \033[3mflight\033[23m\n\nRemoves the given flight from the system. This is permanent and cannot be undone. Use with caution.") + case "delete": + fmt.Println("Format: spacewalk delete \033[3mflight title\033[23m\n\nRemoves the capsule with the given title from the given flight (remove just one capsule from a flight).") + case "show": + fmt.Println("Format: spacewalk show [\033[3mflight\033[23m]\n\nWhen run without a flight, will show basic information for all flights. If a flight is passed then detailed information, including a capsule list, will be shown.") + case "update": + fmt.Println("Format: spacewalk update \033[3mflight item value\033[23m\n\nWill update a flights manifest. Valid items:\n\tlaunch\n\theader\n\tfooter\n\nAll items take a filepath as their value.") + case "help": + fmt.Println("Format: spacewalk help \033[3mcommand\033[0m\n\nWill provide a brief detailed message about the given command. For more detailed information see the man page.") + default: + fmt.Println("Unknown command. Please run: spacewalk help \033[3mcommand\033[23m\nWhere \033[3mcommand\033[23m is any of the following:\n\tcreate\n\tlaunch\n\tadd\n\tremove\n\tdelete\n\tshow\n\tupdate\n\thelp") + } + +} + func update(flight, item, value string) { manifest := readManifest() row := -1 diff --git a/spacewalk.1 b/spacewalk.1 index ac173da..84a4f45 100644 --- a/spacewalk.1 +++ b/spacewalk.1 @@ -62,6 +62,9 @@ When run without a flight name \f[B]show\f[] will show the manifest for each flight. When run with a flight name \f[B]show\f[] will show the manifest for the given flight as well as the log (list of sites) for that flight. +.SS help [\f[I]command\f[]] +.PP +Will display basic help information for the given command. .SS launch [\f[I]flightname\f[]] .PP When run without a flight name \f[B]launch\f[] will launch all available