mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-04 10:26:16 +00:00
add reset command
This commit is contained in:
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2023 Infisical Inc.
|
||||||
|
*/
|
||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/Infisical/infisical-merge/packages/util"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var resetCmd = &cobra.Command{
|
||||||
|
Use: "reset",
|
||||||
|
Short: "Used delete all Infisical related data on your machine",
|
||||||
|
DisableFlagsInUseLine: true,
|
||||||
|
Example: "infisical reset",
|
||||||
|
Args: cobra.NoArgs,
|
||||||
|
PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
|
toggleDebug(cmd, args)
|
||||||
|
},
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
// delete config
|
||||||
|
_, pathToDir, err := util.GetFullConfigFilePath()
|
||||||
|
if err != nil {
|
||||||
|
util.HandleError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println(pathToDir)
|
||||||
|
|
||||||
|
os.RemoveAll(pathToDir)
|
||||||
|
|
||||||
|
// delete keyring
|
||||||
|
keyringInstance, err := util.GetKeyRing()
|
||||||
|
if err != nil {
|
||||||
|
util.HandleError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
keyringInstance.Remove(util.KEYRING_SERVICE_NAME)
|
||||||
|
|
||||||
|
util.PrintSuccessMessage("Reset successful")
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
rootCmd.AddCommand(resetCmd)
|
||||||
|
}
|
||||||
@@ -27,6 +27,10 @@ func PrintWarning(message string) {
|
|||||||
color.New(color.FgYellow).Fprintf(os.Stderr, "Warning: %v \n", message)
|
color.New(color.FgYellow).Fprintf(os.Stderr, "Warning: %v \n", message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func PrintSuccessMessage(message string) {
|
||||||
|
color.New(color.FgGreen).Println(message)
|
||||||
|
}
|
||||||
|
|
||||||
func PrintMessageAndExit(messages ...string) {
|
func PrintMessageAndExit(messages ...string) {
|
||||||
if len(messages) > 0 {
|
if len(messages) > 0 {
|
||||||
for _, message := range messages {
|
for _, message := range messages {
|
||||||
|
|||||||
Reference in New Issue
Block a user