From 64e59b6729c37054a8e1d72f846c9712e4264dca Mon Sep 17 00:00:00 2001 From: amela Date: Fri, 13 Sep 2024 08:23:20 +0200 Subject: [PATCH] feat(cmd/network/remove): Add non-interactive mode --- cmd/network/remove.go | 6 +++++- docs/network.md | 5 +++++ examples/network/remove-y.in.static | 1 + examples/network/remove-y.out.static | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 examples/network/remove-y.in.static create mode 100644 examples/network/remove-y.out.static diff --git a/cmd/network/remove.go b/cmd/network/remove.go index 55694b3a..6629b255 100644 --- a/cmd/network/remove.go +++ b/cmd/network/remove.go @@ -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") } @@ -35,3 +35,7 @@ var rmCmd = &cobra.Command{ cobra.CheckErr(err) }, } + +func init() { + rmCmd.Flags().AddFlagSet(common.AnswerYesFlag) +} diff --git a/docs/network.md b/docs/network.md index 34500a5e..3294fcfc 100644 --- a/docs/network.md +++ b/docs/network.md @@ -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 diff --git a/examples/network/remove-y.in.static b/examples/network/remove-y.in.static new file mode 100644 index 00000000..eeb599ff --- /dev/null +++ b/examples/network/remove-y.in.static @@ -0,0 +1 @@ +oasis network remove testnet -y diff --git a/examples/network/remove-y.out.static b/examples/network/remove-y.out.static new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/examples/network/remove-y.out.static @@ -0,0 +1 @@ +