Skip to content

Commit

Permalink
cmd(remote): add reset command (#644)
Browse files Browse the repository at this point in the history
  • Loading branch information
bobheadxi committed Mar 7, 2020
1 parent 506bd77 commit 1073e3b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
3 changes: 1 addition & 2 deletions cmd/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ func (root *ProjectCmd) attachResetCmd() {
Short: "Remove project configuration",
Long: `Removes your project configuration by deleting the configuration file.
This is irreversible.`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
resp, err := input.Prompt("would you like to reset your project configuration?")
resp, err := input.Prompt("Would you like to reset your project configuration?")
if err != nil {
out.Fatal(err)
}
Expand Down
27 changes: 27 additions & 0 deletions cmd/remote/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ For example:
remote.attachListCmd()
remote.attachRemoveCmd()
remote.attachUpgradeCmd()
remote.attachResetCmd()
remote.attachConfigPathCmd()

// add to parent
Expand Down Expand Up @@ -338,6 +339,32 @@ func (root *RemoteCmd) attachSetCmd() {
root.AddCommand(set)
}

func (root *RemoteCmd) attachResetCmd() {
var resetCmd = &cobra.Command{
Use: "reset",
Short: "Reset all remotes",
Long: `Removes all inertia remotes configuration - use 'inertia remote config-path'
to see where the file is directly. Note that the configuration directory can be set using
INERTIA_PATH.`,
Run: func(cmd *cobra.Command, args []string) {
resp, err := input.Prompt("Would you like to reset ALL remote configuration?")
if err != nil {
out.Fatal(err)
}
if resp == "y" || resp == "yes" {
if err := os.Remove(local.InertiaRemotesPath()); err != nil {
out.Fatal(err)
} else {
println("remote configuration successfully removed")
}
} else {
out.Fatal("aborting")
}
},
}
root.AddCommand(resetCmd)
}

func (root *RemoteCmd) attachConfigPathCmd() {
var cfgPath = &cobra.Command{
Use: "config-path",
Expand Down

0 comments on commit 1073e3b

Please sign in to comment.