forked from bpicode/fritzctl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.go
36 lines (31 loc) · 868 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
32
33
34
35
36
package cmd
import (
"io"
"os"
"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,
}
configReaderSrc io.Reader = os.Stdin
)
func init() {
RootCmd.AddCommand(configureCmd)
}
func configure(_ *cobra.Command, _ []string) error {
configurer := config.NewConfigurer()
configurer.Greet()
cfg, err := configurer.Obtain(configReaderSrc)
assertNoErr(err, "error obtaining configuration")
err = cfg.Write()
assertNoErr(err, "error writing configuration file")
return nil
}