-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathconfig.go
38 lines (33 loc) · 1.24 KB
/
config.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
package config
import (
"fmt"
"github.com/stackitcloud/stackit-cli/internal/cmd/config/list"
"github.com/stackitcloud/stackit-cli/internal/cmd/config/set"
"github.com/stackitcloud/stackit-cli/internal/cmd/config/unset"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
"github.com/spf13/cobra"
)
func NewCmd(p *print.Printer) *cobra.Command {
cmd := &cobra.Command{
Use: "config",
Short: "Provides functionality for CLI configuration options",
Long: fmt.Sprintf("%s\n%s\n%s\n%s\n%s\n%s", "Provides functionality for CLI configuration options",
"The configuration is stored in a file in the user's config directory, which is OS dependent.",
"Windows: %APPDATA%\\stackit",
"Linux: $XDG_CONFIG_HOME/stackit",
"macOS: $HOME/Library/Application Support/stackit",
"The configuration file is named `cli-config.json` and is created automatically in your first CLI run.",
),
Args: args.NoArgs,
Run: utils.CmdHelp,
}
addSubcommands(cmd, p)
return cmd
}
func addSubcommands(cmd *cobra.Command, p *print.Printer) {
cmd.AddCommand(list.NewCmd(p))
cmd.AddCommand(set.NewCmd(p))
cmd.AddCommand(unset.NewCmd(p))
}