-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
59 lines (54 loc) · 1.63 KB
/
main.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"log"
"os"
"github.com/magdyamr542/ssh-tunnel-manager/cmd/add"
"github.com/magdyamr542/ssh-tunnel-manager/cmd/autocomplete"
"github.com/magdyamr542/ssh-tunnel-manager/cmd/edit"
"github.com/magdyamr542/ssh-tunnel-manager/cmd/list"
"github.com/magdyamr542/ssh-tunnel-manager/cmd/remove"
"github.com/magdyamr542/ssh-tunnel-manager/cmd/tunnel"
"github.com/magdyamr542/ssh-tunnel-manager/configmanager"
"github.com/posener/complete/v2"
"github.com/urfave/cli/v2"
)
func main() {
// App
app := &cli.App{
EnableBashCompletion: true,
Name: "ssh-tunnel-manager",
Usage: "An SSH tunnel manager tool with port forwarding capability.",
Description: "Save SSH tunnel configurations and start a tunnel with port forwarding using one of the saved configurations.",
Flags: []cli.Flag{
&cli.StringFlag{
Name: add.ConfigDirFlagName,
Usage: "Path to a directory where configurations are saved",
Value: configmanager.DefaultConfigDir,
},
},
Commands: []*cli.Command{
&list.Cmd,
&add.Cmd,
&remove.Cmd,
&edit.Cmd,
&tunnel.Cmd,
&autocomplete.Cmd,
},
}
// Autocomplete
cmd := &complete.Command{
Sub: map[string]*complete.Command{
list.Cmd.Name: {Args: list.Predictor},
add.Cmd.Name: {Args: list.Predictor, Flags: add.FlagsPredictor},
remove.Cmd.Name: {Args: list.Predictor},
edit.Cmd.Name: {Args: list.Predictor},
tunnel.Cmd.Name: {Args: list.Predictor},
autocomplete.Cmd.Name: {},
},
}
cmd.Complete("ssh-tunnel-manager")
// Run
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}