1
1
/*
2
- Copyright © 2022 NAME HERE <EMAIL ADDRESS >
2
+ Copyright © 2022 Dhruv <[email protected] >
3
3
*/
4
4
package cmd
5
5
6
6
import (
7
- "fmt"
8
7
"os"
9
- "path"
10
- "runtime"
11
8
12
9
"github.com/spf13/cobra"
13
10
)
@@ -26,40 +23,27 @@ type ConList struct {
26
23
27
24
var SshIndexMap = make (map [int ]SshCon )
28
25
var SshShortMap = make (map [string ]SshCon )
29
- var Version = "development "
26
+ var Version = "v1.1.7 "
30
27
31
28
var DATA_PATH string = ""
32
29
var SshList ConList
33
30
34
31
// rootCmd represents the base command when called without any subcommands
35
32
var rootCmd = & cobra.Command {
36
- Use : "sshm" ,
37
- Short : "sshm is a simple cli tool to manage your ssh connections" ,
38
- Long : `sshm is a simple cli tool to manage your ssh connections. You can add,edit and view the connection strings.` ,
39
- // Uncomment the following line if your bare application
40
- // has an action associated with it:
41
- // Run: func(cmd *cobra.Command, args []string) { },
33
+ Use : "sshm" ,
34
+ Short : "sshm is a simple cli tool to manage your ssh connections" ,
35
+ Long : `sshm is a simple cli tool to manage your ssh connections. You can add,edit and delete the connections.` ,
36
+ CompletionOptions : cobra.CompletionOptions {DisableDefaultCmd : true },
42
37
}
43
38
44
- // Execute adds all child commands to the root command and sets flags appropriately.
45
39
// This is called by main.main(). It only needs to happen once to the rootCmd.
46
40
func Execute () {
47
- mydir , erri := os .Getwd ()
48
- if erri != nil {
49
- fmt .Println (erri )
50
- }
51
- fmt .Println ("current working dir is : " , mydir )
52
- _ , filename , _ , ok := runtime .Caller (0 )
53
- if ! ok {
54
- panic ("No caller information" )
55
- }
56
- // fmt.Println(version)
57
- // fmt.Printf("Filename : %q, Dir : %q\n", filename, path.Dir(filename))
58
- fmt .Println (path .Dir (filename ))
59
- // DATA_PATH = path.Dir(filename) + "/data.json"
60
- DATA_PATH = "./data.json"
41
+ dataPath := "./data.json"
42
+
43
+ DATA_PATH = dataPath
61
44
62
45
SshList = LoadData ()
46
+ // fmt.Println(SshIndexMap, SshShortMap)
63
47
err := rootCmd .Execute ()
64
48
if err != nil {
65
49
os .Exit (1 )
@@ -76,4 +60,6 @@ func init() {
76
60
// Cobra also supports local flags, which will only run
77
61
// when this action is called directly.
78
62
// rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
63
+ // rootCmd.CompletionOptions.DisableDefaultCmd = true
64
+
79
65
}
0 commit comments