-
-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathcmd.go
More file actions
66 lines (59 loc) · 2.81 KB
/
cmd.go
File metadata and controls
66 lines (59 loc) · 2.81 KB
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
/*
* Copyright The Microcks Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cmd
import (
"github.com/microcks/microcks-cli/pkg/config"
"github.com/microcks/microcks-cli/pkg/connectors"
"github.com/microcks/microcks-cli/pkg/errors"
"github.com/spf13/cobra"
)
func NewCommad() *cobra.Command {
var clientOpts connectors.ClientOptions
command := &cobra.Command{
Use: "microcks",
Short: "A CLI tool for Microcks",
SilenceUsage: true,
Run: func(cmd *cobra.Command, args []string) {
cmd.HelpFunc()(cmd, args)
},
CompletionOptions: cobra.CompletionOptions{
HiddenDefaultCmd: true,
},
}
command.AddCommand(NewImportCommand(&clientOpts))
command.AddCommand(NewDeleteCommand(&clientOpts))
command.AddCommand(NewImportDirCommand(&clientOpts))
command.AddCommand(NewVersionCommand())
command.AddCommand(NewTestCommand(&clientOpts))
command.AddCommand(NewImportURLCommand(&clientOpts))
command.AddCommand(NewStartCommand(&clientOpts))
command.AddCommand(NewStopCommand(&clientOpts))
command.AddCommand(NewContextCommand(&clientOpts))
command.AddCommand(NewLoginCommand(&clientOpts))
command.AddCommand(NewLogoutCommand(&clientOpts))
defaultLocalConfigPath, err := config.DefaultLocalConfigPath()
errors.CheckError(err)
command.PersistentFlags().StringVar(&clientOpts.ConfigPath, "config", defaultLocalConfigPath, "Path to Microcks config")
command.PersistentFlags().StringVar(&clientOpts.Context, "microcks-context", "", "Name of the Microcks context to use")
command.PersistentFlags().BoolVar(&clientOpts.Verbose, "verbose", false, "Produce dumps of HTTP exchanges")
command.PersistentFlags().BoolVar(&clientOpts.InsecureTLS, "insecure-tls", false, "Whether to accept insecure HTTPS connection")
command.PersistentFlags().StringVar(&clientOpts.CaCertPaths, "caCerts", "", "Comma separated paths of CRT files to add to Root CAs")
command.PersistentFlags().StringVar(&clientOpts.ClientId, "keycloakClientId", "", "Keycloak Realm Service Account ClientId")
command.PersistentFlags().StringVar(&clientOpts.ClientSecret, "keycloakClientSecret", "", "Keycloak Realm Service Account ClientSecret")
command.PersistentFlags().StringVar(&clientOpts.ServerAddr, "microcksURL", "", "Microcks API URL")
command.MarkFlagsRequiredTogether("keycloakClientId", "keycloakClientSecret")
return command
}