-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
97 lines (89 loc) · 2.03 KB
/
main.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package main
import (
"log"
"os"
"strconv"
"time"
"github.com/urfave/cli"
)
// Version Number -ldflags="-X 'main.Version=xX.Y.Z'"
var version string = "0.0.0.0-master"
var compiled string = "1262304000" // 01/01/2010 @ 12:00am
func checkError(e error) {
if e != nil {
println(e.Error())
os.Exit(1)
}
}
func main() {
app := cli.NewApp()
// Build Values - Version String
app.Version = version
// Build Values - Compiled Timestamp from Unix Time String
i, err := strconv.ParseInt(compiled, 10, 64)
if err != nil {
panic(err)
}
app.Compiled = time.Unix(i, 0)
app.Name = "go-nuget"
app.Usage = "An open source nuget clone in Go"
app.Authors = []cli.Author{
cli.Author{
Name: "Sam Shelton",
Email: "sam.shelton@soloworks.co.uk",
},
}
app.Copyright = "(c) 2019 Solo Works London"
// Subcommands
app.Commands = []cli.Command{
{
Name: "pack",
Usage: "Creates a NuGet package based on the specified nuspec file.",
Flags: []cli.Flag{
cli.StringFlag{
Name: "BasePath",
Usage: "Sets the base path of the files defined in the .nuspec file.",
},
cli.StringFlag{
Name: "OutputDirectory",
Usage: "Specifies the folder in which the created package is stored. If no folder is specified, the current folder is used.",
},
cli.StringFlag{
Name: "Version",
Usage: "Overrides the version number from the nuspec file.",
},
},
Action: cliPackNupkg,
},
{
Name: "push",
Usage: "Pushes a package to the server and publishes it.",
Flags: []cli.Flag{
cli.StringFlag{
Name: "ApiKey",
Usage: "The API key for the target repository.",
},
cli.StringFlag{
Name: "Source",
Usage: "Specifies the server URL.",
},
},
Action: cliPushNupkg,
},
{
Name: "spec",
Usage: "Generates a nuspec for a new package.",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "Force",
Usage: "Overwrite nuspec file if it exists",
},
},
Action: cliSampleNuSpec,
},
}
err = app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}