This repository has been archived by the owner on Sep 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demozoo.go
70 lines (65 loc) · 2.29 KB
/
demozoo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//nolint:gochecknoglobals,gochecknoinits
package cmd
import (
"errors"
"os"
"github.com/Defacto2/df2/cmd/internal/arg"
"github.com/Defacto2/df2/cmd/internal/run"
"github.com/Defacto2/df2/pkg/database"
"github.com/spf13/cobra"
)
var zoo arg.Demozoo
// demozooCmd represents the demozoo command.
var demozooCmd = &cobra.Command{
Use: "demozoo",
Short: "Interact with Demozoo submissions.",
Long: `Manage upload submissions that rely on the API hosted on demozoo.org.
There are additional Demozoo commands found under the api command.`,
Aliases: []string{"d", "dz"},
GroupID: "group3",
Example: ` df2 demozoo [--new|--all|--releases|--id] (--overwrite)
df2 demozoo [--ping|--download]`,
Run: func(cmd *cobra.Command, args []string) {
db, err := database.Connect(confg)
if err != nil {
logr.Fatal(err)
}
defer db.Close()
err = run.Demozoo(db, os.Stdout, logr, confg, zoo)
switch {
case errors.Is(err, run.ErrNothing):
if err := cmd.Usage(); err != nil {
logr.Fatal(err)
}
case err != nil:
logr.Error(err)
}
},
}
func init() {
rootCmd.AddCommand(demozooCmd)
demozooCmd.Flags().BoolVarP(&zoo.New, "new", "n", false,
"scan for new demozoo submissions (recommended)")
demozooCmd.Flags().BoolVar(&zoo.All, "all", false,
"scan all local files entries with demozoo links (SLOW)")
demozooCmd.Flags().UintVar(&zoo.Releaser, "releases", 0,
"add to the local files all the productions of a demozoo scener")
demozooCmd.Flags().StringVarP(&zoo.ID, "id", "i", "",
"replace any empty data cells of a local file with linked demozoo data")
demozooCmd.Flags().BoolVar(&zoo.Overwrite, "overwrite", false,
"rescan archives and overwrite all existing assets\n")
demozooCmd.Flags().UintVarP(&zoo.Ping, "ping", "p", 0,
"fetch and display a production record from the demozoo API")
demozooCmd.Flags().UintVarP(&zoo.Download, "download", "g", 0,
"fetch and download a linked file from the demozoo API\n")
demozooCmd.Flags().StringArrayVar(&zoo.Extract, "extract", make([]string, 0),
`extracts and parses an archived file
requires two flags: --extract [filename] --extract [uuid]`)
if err := demozooCmd.MarkFlagFilename("extract"); err != nil {
logr.Error(err)
}
if err := demozooCmd.Flags().MarkHidden("extract"); err != nil {
logr.Error(err)
}
demozooCmd.Flags().SortFlags = false
}