-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetchr.go
76 lines (64 loc) · 1.69 KB
/
fetchr.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
package main
import (
"fmt"
"github.com/analogj/go-util/utils"
"github.com/packagrio/fetchr/pkg/actions/query"
"github.com/packagrio/fetchr/pkg/report"
"github.com/packagrio/fetchr/pkg/version"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
"log"
"os"
"time"
)
var goos string
var goarch string
func main() {
app := &cli.App{
Name: "fetchr",
Usage: "Universal tool to retrieve packages/artifacts using PackageUrls (PURL)",
Version: version.VERSION,
Compiled: time.Now(),
Authors: []*cli.Author{
&cli.Author{
Name: "Jason Kulatunga",
Email: "jason@thesparktree.com",
},
},
Before: func(c *cli.Context) error {
packagrUrl := "github.com/packagrio/fetchr"
versionInfo := fmt.Sprintf("%s.%s-%s", goos, goarch, version.VERSION)
subtitle := packagrUrl + utils.LeftPad2Len(versionInfo, " ", 53-len(packagrUrl))
fmt.Fprintf(c.App.Writer, fmt.Sprintf(utils.StripIndent(
`
____ __ ___ __ _ __ ___ ____
( _ \ / _\ / __)( / ) / _\ / __)( _ \
) __// \( (__ ) ( / \( (_ \ ) /
(__) \_/\_/ \___)(__\_)\_/\_/ \___/(__\_)
%s
`), subtitle))
return nil
},
Commands: []*cli.Command{
{
Name: "query",
Usage: "universal artifact search using Purl artifact ids",
Action: func(c *cli.Context) error {
pipeline := query.Pipeline{
Config: query.NewConfiguration(),
ArtifactPurlStr: c.Args().Get(0),
Logger: logrus.New(),
}
queryResults, err := pipeline.Start()
report.QueryReportMarkdown(queryResults)
return err
},
Flags: []cli.Flag{},
},
},
}
err := app.Run(os.Args)
if err != nil {
log.Fatalf("ERROR: %v", err)
}
}