-
Notifications
You must be signed in to change notification settings - Fork 72
/
context.go
70 lines (59 loc) · 2.89 KB
/
context.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
package context
import (
namespaceUse "github.com/redhat-developer/app-services-cli/pkg/cmd/connector/namespace/use"
connectorUse "github.com/redhat-developer/app-services-cli/pkg/cmd/connector/use"
"github.com/redhat-developer/app-services-cli/pkg/cmd/context/create"
"github.com/redhat-developer/app-services-cli/pkg/cmd/context/delete"
"github.com/redhat-developer/app-services-cli/pkg/cmd/context/list"
"github.com/redhat-developer/app-services-cli/pkg/cmd/context/unset"
"github.com/redhat-developer/app-services-cli/pkg/cmd/context/use"
kafkaUse "github.com/redhat-developer/app-services-cli/pkg/cmd/kafka/use"
registryUse "github.com/redhat-developer/app-services-cli/pkg/cmd/registry/use"
"github.com/redhat-developer/app-services-cli/pkg/cmd/status"
"github.com/redhat-developer/app-services-cli/pkg/shared/factory"
"github.com/spf13/cobra"
)
// NewContextCmd creates a new command to manage service contexts
func NewContextCmd(f *factory.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "context",
Short: f.Localizer.MustLocalize("context.cmd.shortDescription"),
Long: f.Localizer.MustLocalize("context.cmd.longDescription"),
Example: f.Localizer.MustLocalize("context.cmd.example"),
Args: cobra.NoArgs,
}
// The implementation of `rhoas kafka use` command has been aliased here as `rhoas context set-kafka`
kafkaUseCmd := kafkaUse.NewUseCommand(f)
kafkaUseCmd.Use = "set-kafka"
kafkaUseCmd.Example = f.Localizer.MustLocalize("context.setKafka.cmd.example")
// The implementation of `rhoas connector namespace use` command has been aliased here as `rhoas context set-namespace`
connectorUseCmd := connectorUse.NewUseCommand(f)
connectorUseCmd.Use = "set-connector"
connectorUseCmd.Example = f.Localizer.MustLocalize("context.setConnector.cmd.example")
// The implementation of `rhoas connector use` command has been aliased here as `rhoas context set-connector`
namespaceUseCmd := namespaceUse.NewUseCommand(f)
namespaceUseCmd.Use = "set-namespace"
namespaceUseCmd.Example = f.Localizer.MustLocalize("context.setNamespace.cmd.example")
// `rhoas status` cmd has been re-used as `rhoas context status`
statusCmd := status.NewStatusCommand(f)
statusCmd.Long = f.Localizer.MustLocalize("context.status.cmd.longDescription")
statusCmd.Example = f.Localizer.MustLocalize("context.status.cmd.example")
// The implementation of `rhoas service-registry use` command has been aliased here as `rhoas context set-service-registry`
registryUseCmd := registryUse.NewUseCommand(f)
registryUseCmd.Use = "set-service-registry"
registryUseCmd.Example = f.Localizer.MustLocalize("context.setRegistry.cmd.example")
cmd.AddCommand(
use.NewUseCommand(f),
list.NewListCommand(f),
create.NewCreateCommand(f),
delete.NewDeleteCommand(f),
unset.NewUnsetCommand(f),
// reused sub-commands
kafkaUseCmd,
connectorUseCmd,
namespaceUseCmd,
registryUseCmd,
statusCmd,
)
return cmd
}