Documentation
¶
Overview ¶
Package db /*
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ConfigCmd = &cobra.Command{ Use: "config", Short: "Show the current Pennsieve configuration file.", Long: `Show the current Pennsieve configuration file.`, Run: func(cmd *cobra.Command, args []string) { home, err := os.UserHomeDir() pennsieveFolder := filepath.Join(home, ".pennsieve") configFile := filepath.Join(pennsieveFolder, "config.ini") data, err := ioutil.ReadFile(configFile) if err != nil { fmt.Println("Unable to render Pennsieve configuration file.") os.Exit(1) } fmt.Println(string(data)) }, }
View Source
var WizardCmd = &cobra.Command{ Use: "wizard", Short: "Create a new config file using the configuration wizard.", Long: `Create a new config file using the configuration wizard. `, Run: func(cmd *cobra.Command, args []string) { home, err := os.UserHomeDir() pennsieveFolder := filepath.Join(home, ".pennsieve") configFile := filepath.Join(pennsieveFolder, "config.ini") _, err = os.Stat(configFile) if err == nil { fmt.Println("Existing configuration file found at:", configFile) fmt.Printf("\nWould you like to overwrite your existing configuration? (y/n): ") response := "" fmt.Scanln(&response) if response != "y" { return } os.Remove(configFile) } fmt.Println("\nCreating new configuration file at", configFile) if _, err := os.Stat(pennsieveFolder); errors.Is(err, os.ErrNotExist) { if err := os.Mkdir(pennsieveFolder, os.ModePerm); err != nil { log.Fatal(err) } } var profileName string fmt.Println("\nCreate new profile:") fmt.Printf(" Profile name [user]: ") fmt.Scanln(&profileName) if len(profileName) == 0 { profileName = "user" } var apiToken string fmt.Printf(" API token: ") fmt.Scanln(&apiToken) var apiSecret string fmt.Printf(" API secret: ") fmt.Scanln(&apiSecret) fmt.Printf("Creating new profile: '%s'\n", profileName) fmt.Printf("Continue and write changes? (y/n) ") response := "" fmt.Scanln(&response) if response == "y" { viper.Set(fmt.Sprintf("%s.api_token", profileName), apiToken) viper.Set(fmt.Sprintf("%s.api_secret", profileName), apiSecret) viper.Set("global.default_profile", profileName) err = viper.SafeWriteConfig() if err != nil { fmt.Println(err) } } }, }
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.