This repository has been archived by the owner on Nov 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd.go
51 lines (40 loc) · 1.57 KB
/
cmd.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
package cli
import (
"github.com/dpb587/boshua/config/provider/setter"
cmdopts "github.com/dpb587/boshua/main/boshua/cmd/opts"
"github.com/dpb587/boshua/stemcellversion/cli/analysis"
"github.com/dpb587/boshua/stemcellversion/cli/datastore"
"github.com/dpb587/boshua/stemcellversion/cli/opts"
)
type CmdOpts struct {
StemcellOpts *opts.Opts
}
type Cmd struct {
setter.AppConfig `no-flag:"true"`
*opts.Opts
AnalysisCmd *analysis.Cmd `command:"analysis" description:"For analyzing the stemcell artifact" subcommands-optional:"true"`
DatastoreCmd *datastore.Cmd `command:"datastore" description:"For interacting with release datastores"`
AnalyzersCmd AnalyzersCmd `command:"analyzers" description:"For showing the supported analyzers"`
ArtifactCmd ArtifactCmd `command:"artifact" description:"For showing the stemcell artifact"`
UploadStemcellCmd UploadStemcellCmd `command:"upload-stemcell" description:"For uploading the stemcell to BOSH"`
DownloadCmd DownloadCmd `command:"download" description:"For downloading the stemcell locally"`
}
func (c *Cmd) Execute(extra []string) error {
c.ArtifactCmd.SetConfig(c.AppConfig.Config)
return c.ArtifactCmd.Execute(extra)
}
func New(app *cmdopts.Opts) *Cmd {
cmd := &Cmd{
Opts: &opts.Opts{},
}
cmd.AnalysisCmd = analysis.New(app, cmd.Opts)
cmd.DatastoreCmd = datastore.New(app, cmd.Opts)
cmdOpts := &CmdOpts{
StemcellOpts: cmd.Opts,
}
cmd.AnalyzersCmd.CmdOpts = cmdOpts
cmd.ArtifactCmd.CmdOpts = cmdOpts
cmd.UploadStemcellCmd.CmdOpts = cmdOpts
cmd.DownloadCmd.CmdOpts = cmdOpts
return cmd
}