PKGBUILD/cmd/remote/list.go

44 lines
772 B
Go
Raw Normal View History

2018-11-19 21:36:21 +00:00
package remote
import (
"log"
"os"
"git.cryptic.systems/fh-trier/go-flucky/pkg/cli"
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{
2019-02-22 12:08:58 +00:00
Use: "ls",
Short: "List Remove Servers",
2019-02-22 12:08:58 +00:00
Aliases: []string{"list"},
Example: "flucky remote 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 = cli.PrintRemotes(fc, os.Stdout)
2019-02-17 17:23:59 +00:00
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)
}