mirror of
https://git.sr.ht/~joren/streamrip-go
synced 2026-07-27 23:42:28 +02:00
feat: add cli help menus
This commit is contained in:
+35
-17
@@ -25,10 +25,34 @@ func main() {
|
||||
fmt.Fprintf(os.Stderr, "option error: %v\n", err)
|
||||
os.Exit(2)
|
||||
}
|
||||
if gopts.help {
|
||||
printMainHelp(os.Stdout)
|
||||
return
|
||||
}
|
||||
if gopts.command == "" {
|
||||
fmt.Println("usage: rip <command>")
|
||||
fmt.Println("commands: url, file, config, database, id, search, lastfm")
|
||||
fmt.Println("tip: run `rip dev-help` to list developer smoke commands")
|
||||
printMainHelp(os.Stdout)
|
||||
os.Exit(2)
|
||||
}
|
||||
if gopts.command == "help" {
|
||||
if len(gopts.commandArgs) == 0 || isHelpArg(gopts.commandArgs[0]) {
|
||||
printMainHelp(os.Stdout)
|
||||
return
|
||||
}
|
||||
if printCommandHelp(os.Stdout, gopts.commandArgs[0]) {
|
||||
return
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "unknown help topic: %s\n", gopts.commandArgs[0])
|
||||
os.Exit(2)
|
||||
}
|
||||
if gopts.command == "dev-help" {
|
||||
printDeveloperHelp(os.Stdout)
|
||||
return
|
||||
}
|
||||
if commandWantsHelp(gopts.commandArgs) {
|
||||
if printCommandHelp(os.Stdout, gopts.command) {
|
||||
return
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "unknown command: %s\n", gopts.command)
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
@@ -64,17 +88,11 @@ func main() {
|
||||
|
||||
switch os.Args[1] {
|
||||
case "dev-help":
|
||||
fmt.Println("developer smoke commands:")
|
||||
fmt.Println(" soundcloud-smoke")
|
||||
fmt.Println(" qobuz-smoke, qobuz-rip-smoke, qobuz-convert-rip-smoke")
|
||||
fmt.Println(" qobuz-album-rip-smoke, qobuz-playlist-rip-smoke, qobuz-artist-rip-smoke, qobuz-label-rip-smoke")
|
||||
fmt.Println(" qobuz-search-smoke")
|
||||
fmt.Println(" tidal-search-smoke, tidal-metadata-smoke, tidal-video-smoke")
|
||||
fmt.Println(" tidal-rip-smoke, tidal-album-rip-smoke, tidal-playlist-rip-smoke, tidal-artist-rip-smoke")
|
||||
printDeveloperHelp(os.Stdout)
|
||||
return
|
||||
case "url":
|
||||
if len(os.Args) < 3 {
|
||||
fmt.Println("usage: rip url <url...> [--force|--ignore-db]")
|
||||
printCommandHelp(os.Stdout, "url")
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
@@ -119,7 +137,7 @@ func main() {
|
||||
fmt.Printf("url rip complete (%d item(s))\n", added)
|
||||
case "file":
|
||||
if len(os.Args) < 3 {
|
||||
fmt.Println("usage: rip file <path> [--force|--ignore-db]")
|
||||
printCommandHelp(os.Stdout, "file")
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
@@ -192,7 +210,7 @@ func main() {
|
||||
fmt.Printf("file rip complete (%d item(s))\n", added)
|
||||
case "config":
|
||||
if len(os.Args) < 3 {
|
||||
fmt.Println("usage: rip config <open|reset|path> [options]")
|
||||
printCommandHelp(os.Stdout, "config")
|
||||
os.Exit(2)
|
||||
}
|
||||
switch os.Args[2] {
|
||||
@@ -258,7 +276,7 @@ func main() {
|
||||
}
|
||||
case "database":
|
||||
if len(os.Args) < 4 || os.Args[2] != "browse" {
|
||||
fmt.Println("usage: rip database browse <downloads|failed>")
|
||||
printCommandHelp(os.Stdout, "database")
|
||||
os.Exit(2)
|
||||
}
|
||||
table := strings.ToLower(strings.TrimSpace(os.Args[3]))
|
||||
@@ -294,7 +312,7 @@ func main() {
|
||||
}
|
||||
case "id":
|
||||
if len(os.Args) < 5 {
|
||||
fmt.Println("usage: rip id <source> <track|album|playlist|artist|label|chart|video> <id> [quality] [--force|--ignore-db]")
|
||||
printCommandHelp(os.Stdout, "id")
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
@@ -354,7 +372,7 @@ func main() {
|
||||
var sopts searchOptions
|
||||
if len(os.Args) < 5 {
|
||||
if !term.IsTerminal(int(os.Stdin.Fd())) {
|
||||
fmt.Println("usage: rip search <qobuz|tidal|deezer|yandex|beatport|soundcloud> <track|album|playlist|artist|label|chart|video> <query...> [--limit N] [--force|--ignore-db] [--no-download]")
|
||||
printCommandHelp(os.Stdout, "search")
|
||||
os.Exit(2)
|
||||
}
|
||||
source, mediaType, sopts, err = promptSearchInteractive(cfg.Session.CLI.MaxSearchResults)
|
||||
@@ -549,7 +567,7 @@ func main() {
|
||||
opts, parseErr := parseLastFMArgs(os.Args[2:], cfg.Session.LastFM.Source, cfg.Session.LastFM.FallbackSource)
|
||||
if parseErr != nil {
|
||||
fmt.Fprintf(os.Stderr, "lastfm option error: %v\n", parseErr)
|
||||
fmt.Println("usage: rip lastfm [--source SOURCE] [--fallback-source SOURCE] <playlist_url>")
|
||||
printCommandHelp(os.Stdout, "lastfm")
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user