Skip to content

Commit

Permalink
feat(cmd/network/remove): Add non-interactive mode
Browse files Browse the repository at this point in the history
  • Loading branch information
amela committed Sep 13, 2024
1 parent 4f90a49 commit 64e59b6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/network/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var rmCmd = &cobra.Command{
cobra.CheckErr(fmt.Errorf("network '%s' does not exist", name))
}

if len(net.ParaTimes.All) > 0 {
if !common.GetAnswerYes() && len(net.ParaTimes.All) > 0 {
fmt.Printf("WARNING: Network '%s' contains %d ParaTimes.\n", name, len(net.ParaTimes.All))
common.Confirm("Are you sure you want to remove the network?", "not removing network")
}
Expand All @@ -35,3 +35,7 @@ var rmCmd = &cobra.Command{
cobra.CheckErr(err)
},
}

func init() {
rmCmd.Flags().AddFlagSet(common.AnswerYesFlag)
}
5 changes: 5 additions & 0 deletions docs/network.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ all dependant ParaTimes.

![code shell](../examples/network/01-remove.in)

You can also delete network in non-interactive mode format by passing the
`-y` parameter:

![code shell](../examples/network/remove-y.in.static)

## Set Network Chain Context {#set-chain-context}

To change the chain context of a network, use
Expand Down
1 change: 1 addition & 0 deletions examples/network/remove-y.in.static
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oasis network remove testnet -y
1 change: 1 addition & 0 deletions examples/network/remove-y.out.static
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit 64e59b6

Please sign in to comment.