-
Notifications
You must be signed in to change notification settings - Fork 11
/
cli.go
73 lines (60 loc) · 2.12 KB
/
cli.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
package cli
import (
"os"
"github.com/anchore/clio"
"github.com/anchore/quill/cmd/quill/cli/commands"
"github.com/anchore/quill/cmd/quill/internal/ui"
"github.com/anchore/quill/internal/bus"
"github.com/anchore/quill/internal/log"
"github.com/anchore/quill/internal/redact"
)
func New(id clio.Identification) clio.Application {
clioCfg := clio.NewSetupConfig(id).
WithGlobalConfigFlag(). // add persistent -c <path> for reading an application config from
WithGlobalLoggingFlags(). // add persistent -v and -q flags tied to the logging config
WithConfigInRootHelp(). // --help on the root command renders the full application config in the help text
WithUIConstructor(
// select a UI based on the logging configuration and state of stdin (if stdin is a tty)
func(cfg clio.Config) ([]clio.UI, error) {
noUI := ui.None()
if !cfg.Log.AllowUI(os.Stdin) {
return []clio.UI{noUI}, nil
}
return []clio.UI{
ui.New(false, cfg.Log.Quiet),
noUI,
}, nil
},
).
WithInitializers(
func(state *clio.State) error {
// clio is setting up and providing the bus, redact store, and logger to the application. Once loaded,
// we can hoist them into the internal packages for global use.
bus.Set(state.Bus)
redact.Set(state.RedactStore)
log.Set(state.Logger)
return nil
},
)
app := clio.New(*clioCfg)
root := commands.Root(app)
submission := commands.Submission(app)
submission.AddCommand(commands.SubmissionList(app))
submission.AddCommand(commands.SubmissionStatus(app))
submission.AddCommand(commands.SubmissionLogs(app))
extract := commands.Extract(app)
extract.AddCommand(commands.ExtractCertificates(app))
p12 := commands.P12(app)
p12.AddCommand(commands.P12AttachChain(app))
p12.AddCommand(commands.P12Describe(app))
root.AddCommand(clio.VersionCommand(id))
root.AddCommand(commands.Sign(app))
root.AddCommand(commands.Notarize(app))
root.AddCommand(commands.SignAndNotarize(app))
root.AddCommand(commands.Describe(app))
root.AddCommand(commands.EmbeddedCerts(app))
root.AddCommand(submission)
root.AddCommand(extract)
root.AddCommand(p12)
return app
}