mirror of
https://github.com/passbolt/go-passbolt-cli.git
synced 2025-09-13 14:59:09 +00:00
add basic operational commands
This commit is contained in:
parent
64c878c9d5
commit
219c451098
12 changed files with 898 additions and 0 deletions
38
cmd/configure.go
Normal file
38
cmd/configure.go
Normal file
|
@ -0,0 +1,38 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
// configureCmd represents the configure command
|
||||
var configureCmd = &cobra.Command{
|
||||
Use: "configure",
|
||||
Short: "configure saves the provided global flags to the config file",
|
||||
Long: `configure saves the provided global flags to the config file.
|
||||
this makes using the cli easier as they don't have to be specifed all the time.`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
|
||||
if viper.ConfigFileUsed() == "" {
|
||||
err := viper.SafeWriteConfig()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Writing Config: %w", err)
|
||||
}
|
||||
} else {
|
||||
err := viper.WriteConfig()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Writing Config: %w", err)
|
||||
}
|
||||
}
|
||||
if viper.GetBool("debug") {
|
||||
fmt.Printf("Saved: %+v\n", viper.AllSettings())
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(configureCmd)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue