-
Notifications
You must be signed in to change notification settings - Fork 1
/
vpnShowTech.go
43 lines (36 loc) · 997 Bytes
/
vpnShowTech.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
43
package cmd
import (
"github.com/sam7r/nordnm/nordvpn"
"github.com/sam7r/nordnm/utils"
"os"
"github.com/jedib0t/go-pretty/table"
"github.com/spf13/cobra"
)
// vpnShowTechCmd represents the vpn command
var vpnShowTechCmd = &cobra.Command{
Use: "tech",
Short: "Show available technologies",
Long: `Show all available technologies, these can be used to target servers via the list command using --technology=IDENTIFIER`,
Run: func(cmd *cobra.Command, args []string) {
resp, err := nordvpn.GetTechnologies()
if err != nil {
utils.Logger.Errorf("Getting technologies failed: %v", err)
}
// create new table for output
t := table.NewWriter()
t.SetOutputMirror(os.Stdout)
t.AppendHeader(table.Row{"ID", "NAME", "IDENTIFIER"})
for _, technology := range resp {
// create output rows
t.AppendRow([]interface{}{
technology.ID,
technology.Name,
technology.Identifier,
})
}
t.Render()
},
}
func init() {
vpnShowCmd.AddCommand(vpnShowTechCmd)
}