func rm()

in cli/cmd/rm.go [29:61]


func rm(cmd *cobra.Command, args []string) {
	if Project == "" {
		altProjectSources()
	}
	fmt.Printf("Do you really want to remove the remote state of the stack [%s]? (type Y or Yes) ", args[0])
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	text = strings.Replace(text, "\n", "", -1)
	if text == "Y" || text == "Yes" {
		req, err := NewRequest()
		if err != nil {
			fmt.Printf("Error: %s", err)
			return
		}

		resp, err := req.
			Delete(fmt.Sprintf("%s/%s", baseURL(), args[0]))
		if err != nil {
			fmt.Printf("Error: %s", err)
			return
		}
		if resp.IsSuccess() {
			fmt.Printf("State \"%s\" is removed", args[0])
			return
		}
		if resp.StatusCode() == 404 {
			fmt.Printf("Error: State \"%s\" not found", args[0])
			return
		}
		fmt.Printf("Error: %s", resp.Status())
		return
	}
}