forked from bpicode/fritzctl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.go
31 lines (27 loc) · 833 Bytes
/
configure.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
package cmd
import (
"github.com/bpicode/fritzctl/assert"
"github.com/bpicode/fritzctl/config"
"github.com/spf13/cobra"
)
var configureCmd = &cobra.Command{
Use: "configure",
Short: "Configure fritzctl",
Long: `Walk through the configuration of fritzctl interactively.
Configuration file is saved at the end of the survey.",
Run fritzctl with administrator privileges if the configuration file cannot be saved by a normal user.`,
Example: "fritzctl configure",
RunE: configure,
}
func init() {
RootCmd.AddCommand(configureCmd)
}
func configure(cmd *cobra.Command, args []string) error {
configurer := config.NewConfigurer()
configurer.ApplyDefaults(config.Defaults())
configurer.Greet()
configurer.Obtain()
err := configurer.Write()
assert.NoError(err, "error writing configuration file:", err)
return nil
}