2018-11-19 21:36:21 +00:00
|
|
|
package remote
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
|
2019-02-17 17:23:59 +00:00
|
|
|
"git.cryptic.systems/fh-trier/go-flucky/pkg/config"
|
2018-11-19 21:36:21 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2018-11-28 17:11:15 +00:00
|
|
|
var quiet bool
|
|
|
|
|
2018-11-19 21:36:21 +00:00
|
|
|
var listRemoteCmd = &cobra.Command{
|
2018-12-07 21:50:28 +00:00
|
|
|
Use: "list",
|
|
|
|
Short: "List Remove Servers",
|
|
|
|
Aliases: []string{"ls"},
|
2018-11-19 21:36:21 +00:00
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
|
|
|
2019-02-17 17:23:59 +00:00
|
|
|
// read configuration
|
|
|
|
fc, err := config.Read(cfg)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalln(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// print all configured remote addresses on stdout
|
|
|
|
err = fc.PrintRemotes(os.Stdout)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalln(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// save new configuration
|
|
|
|
err = config.Write(fc, cfg)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalln(err)
|
2018-11-19 21:36:21 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
remoteCmd.AddCommand(listRemoteCmd)
|
|
|
|
}
|