Added --help parameter + README
This commit is contained in:
parent
d4836c1d95
commit
b8859acc28
28
README.md
Normal file
28
README.md
Normal file
@ -0,0 +1,28 @@
|
||||
# Medialog
|
||||
|
||||
```
|
||||
Usage: go run main.go [--media ediatype] [--update]
|
||||
|
||||
Description:
|
||||
This command allows you to manage multimedia files and update their data in the system.
|
||||
|
||||
Options:
|
||||
--media <mediatype> Specifies the type of media to process.
|
||||
Possible values are:
|
||||
- movies: Processes movie files.
|
||||
- series: Processes series files.
|
||||
- books: Processes book files.
|
||||
- games: Processes game files.
|
||||
- music: Processes music files.
|
||||
If not specified, all media types will be processed.
|
||||
|
||||
--update Runs in update mode to refresh existing media entries.
|
||||
This option is optional and requires no value.
|
||||
|
||||
-h, --help Displays this help message and exits.
|
||||
|
||||
Usage examples:
|
||||
go run main.go --media movies Processes only movie files.
|
||||
go run main.go --update Updates all multimedia files.
|
||||
go run main.go --media series --update Processes and updates series files.
|
||||
```
|
40
main.go
40
main.go
@ -9,6 +9,7 @@ import (
|
||||
"hugo-medialog/internal/music"
|
||||
"hugo-medialog/internal/series"
|
||||
"hugo-medialog/utils"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -18,8 +19,18 @@ func main() {
|
||||
// --media parameter
|
||||
media := flag.String("media", "", "Specify the media type to process: movies, series, books, games, or music")
|
||||
update := flag.Bool("update", false, "Run in update mode to update existing entries")
|
||||
|
||||
// Define custom help option
|
||||
help := flag.Bool("help", false, "Display this help message")
|
||||
flag.BoolVar(help, "h", false, "Display this help message") // support -h as well
|
||||
flag.Parse()
|
||||
|
||||
// Show help message if -h or --help is specified
|
||||
if *help {
|
||||
printHelp()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
if *media == "" {
|
||||
processAll(*update)
|
||||
} else {
|
||||
@ -36,6 +47,8 @@ func main() {
|
||||
processMusic(*update)
|
||||
default:
|
||||
fmt.Printf("Invalid media type: %s. Please use movies, series, books, games, or music.\n", *media)
|
||||
printHelp()
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -107,3 +120,30 @@ func processMusic(update bool) {
|
||||
fmt.Printf("Error processing music: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
func printHelp() {
|
||||
fmt.Println(`Usage: go run main.go [--media mediatype] [--update]
|
||||
|
||||
Description:
|
||||
This command allows you to manage multimedia files and update their data in the system.
|
||||
|
||||
Options:
|
||||
--media <mediatype> Specifies the type of media to process.
|
||||
Possible values are:
|
||||
- movies: Processes movie files.
|
||||
- series: Processes series files.
|
||||
- books: Processes book files.
|
||||
- games: Processes game files.
|
||||
- music: Processes music files.
|
||||
If not specified, all media types will be processed.
|
||||
|
||||
--update Runs in update mode to refresh existing media entries.
|
||||
This option is optional and requires no value.
|
||||
|
||||
-h, --help Displays this help message and exits.
|
||||
|
||||
Usage examples:
|
||||
go run main.go --media movies Processes only movie files.
|
||||
go run main.go --update Updates all multimedia files.
|
||||
go run main.go --media series --update Processes and updates series files.`)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user