Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Display = &cobra.Command{ Use: "print [profile]", Args: cobra.ExactArgs(1), Short: "Print out configuration file", Long: "Print out configuration file", Run: func(cmd *cobra.Command, args []string) { name := args[0] cfg := viper.Get(name) fmt.Printf("%s\n", cfg) }, } )
View Source
var ( Load = &cobra.Command{ Use: "load [profile name]", Args: cobra.ExactArgs(1), Short: "Write existing profile to current ssh configuration", Long: "Write existing profile to current ssh configuration", Run: func(cmd *cobra.Command, args []string) { name := args[0] if err := viper.ReadInConfig(); err == nil { if h, err := os.UserHomeDir(); err == nil { config_file := filepath.Join(h, ".ssh", "config") profile_contents := viper.GetString(name) if err := ioutil.WriteFile(config_file, []byte(profile_contents), 500); err == nil { fmt.Println("Successfully loaded new profile!") } else { log.Fatalln(err) } } else { log.Fatalln(err) } } else { log.Fatalln(err) } }, } )
View Source
var ( New = &cobra.Command{ Use: "save [profile]", Args: cobra.ExactArgs(1), Short: "Save a new profile", Long: "Save a new profile", Run: func(cmd *cobra.Command, args []string) { name := args[0] if err := viper.ReadInConfig(); err == nil { if debug { log.Println("Successfully read in existing configuration file: ", viper.ConfigFileUsed()) } } else { log.Fatalln("Error reading viper config: ", err) } if h, err := os.UserHomeDir(); err == nil { config_file := filepath.Join(h, ".ssh", "config") if debug { log.Printf("Checking SSH Config at: %s\n", config_file) } if _, err := os.Stat(config_file); err == nil { log.Printf("File exists, creating SSH profile entry\n") if data, err := ioutil.ReadFile(config_file); err == nil { viper.Set(name, string(data)) if err := viper.WriteConfig(); err == nil { log.Println("Successfully wrote new profile!") } else { log.Fatalln("Error writing to profiler: ", err) } } else { log.Fatalln("Error reading ssh config: ", err) } } } else { log.Fatalln("Error finding ssh directory: ", err) } }, } )
View Source
var ( Ssh = &cobra.Command{ Use: "ssh", Short: "A profiling system for the SSH config file", Long: "A profiling system for the SSH config file", Run: func(cmd *cobra.Command, args []string) { if len(args) == 0 { cmd.Help() os.Exit(0) } }, } )
Ssh is largely clerical, will link sub commands here
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.