forked from bpicode/fritzctl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.go
40 lines (33 loc) · 1023 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
37
38
39
40
package cmd
import (
"strings"
"github.com/bpicode/fritzctl/assert"
"github.com/bpicode/fritzctl/config"
"github.com/mitchellh/cli"
)
type configureCommand struct {
}
func (cmd *configureCommand) Help() string {
return strings.Join([]string{
"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.",
}, "\n")
}
func (cmd *configureCommand) Synopsis() string {
return "configure fritzctl"
}
func (cmd *configureCommand) Run(args []string) int {
configurer := config.NewConfigurer()
configurer.ApplyDefaults(config.Defaults())
configurer.Greet()
configurer.Obtain()
err := configurer.Write()
assert.NoError(err, "error writing configuration file:", err)
return 0
}
// Configure is a factory creating commands for interactive fritzctl configuration.
func Configure() (cli.Command, error) {
p := configureCommand{}
return &p, nil
}