You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.go 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // yt-mango: YT video metadata archiving utility
  2. // Copyright (C) 2018 terorie
  3. package main
  4. import (
  5. "github.com/spf13/cobra"
  6. "fmt"
  7. "os"
  8. "github.com/terorie/yt-mango/cmd"
  9. "log"
  10. )
  11. const Version = "v0.1 -- dev"
  12. func printVersion(_ *cobra.Command, _ []string) {
  13. fmt.Println("YT-Mango archiver", Version)
  14. }
  15. func main() {
  16. // All diagnostics (logging) should go to stderr
  17. log.SetOutput(os.Stderr)
  18. var printVersion bool
  19. rootCmd := cobra.Command{
  20. Use: "yt-mango",
  21. Short: "YT-Mango is a scalable video metadata archiver",
  22. Long: "YT-Mango is a scalable video metadata archiving utility\n" +
  23. "written by terorie for https://the-eye.eu/",
  24. PreRun: func(cmd *cobra.Command, args []string) {
  25. if printVersion {
  26. fmt.Println(Version)
  27. os.Exit(0)
  28. }
  29. },
  30. }
  31. rootCmd.Flags().BoolVar(&printVersion, "version", false,
  32. fmt.Sprintf("Print the version (" + Version +") and exit"), )
  33. rootCmd.AddCommand(&cmd.Channel)
  34. rootCmd.AddCommand(&cmd.Video)
  35. if err := rootCmd.Execute(); err != nil {
  36. fmt.Fprintln(os.Stderr, err)
  37. os.Exit(1)
  38. }
  39. }