-
Notifications
You must be signed in to change notification settings - Fork 6
/
useservercmd.go
42 lines (35 loc) · 1.18 KB
/
useservercmd.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
41
42
package gincmd
import (
"fmt"
ginclient "github.com/G-Node/gin-cli/ginclient"
"github.com/spf13/cobra"
)
func useServer(cmd *cobra.Command, args []string) {
if len(args) > 0 {
name := args[0]
err := ginclient.SetDefaultServer(name)
CheckError(err)
}
name := ginclient.DefaultServer()
fmt.Printf(":: Default server: %s\n", name)
}
// UseServerCmd sets up the 'use-server' subcommand
func UseServerCmd() *cobra.Command {
description := `Set the default GIN server for user and repository management commands.
The following commands are affected by this setting:
create, info, keys, login, logout, repoinfo, repos
This setting can be overridden in each command by using the --server flag.
With no arguments, this command simply prints the currently configured default server.`
args := map[string]string{
"<name>": "The name of the server to use by default",
}
var cmd = &cobra.Command{
Use: "use-server [<name>]",
Short: "Set the default server for the client",
Long: formatdesc(description, args),
Args: cobra.MaximumNArgs(1),
Run: useServer,
DisableFlagsInUseLine: true,
}
return cmd
}