From 0769d590540030f04a9d65320d911700cdd1ec7b Mon Sep 17 00:00:00 2001 From: KaibutsuX <36962438+KaibutsuX@users.noreply.github.com> Date: Tue, 10 Oct 2023 15:24:02 -0400 Subject: [PATCH] feat(cli): added --confirm/-c argument when deleting users to bypass prompt (#86) Reviewed-On: https://github.com/go-vikunja/api/pull/86 --- pkg/cmd/user.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/user.go b/pkg/cmd/user.go index 13194b83564..97e0cde8d06 100644 --- a/pkg/cmd/user.go +++ b/pkg/cmd/user.go @@ -46,6 +46,7 @@ var ( userFlagEnableUser bool userFlagDisableUser bool userFlagDeleteNow bool + userFlagDeleteConfirm bool ) func init() { @@ -73,6 +74,9 @@ func init() { // User deletion flags userDeleteCmd.Flags().BoolVarP(&userFlagDeleteNow, "now", "n", false, "If provided, deletes the user immediately instead of sending them an email first.") + // Bypass confirm prompt + userDeleteCmd.Flags().BoolVarP(&userFlagDeleteConfirm, "confirm", "c", false, "Bypasses any prompts confirming the deletion request, use with caution!") + userCmd.AddCommand(userListCmd, userCreateCmd, userUpdateCmd, userResetPasswordCmd, userChangeEnabledCmd, userDeleteCmd) rootCmd.AddCommand(userCmd) } @@ -326,7 +330,7 @@ var userDeleteCmd = &cobra.Command{ initialize.FullInit() }, Run: func(cmd *cobra.Command, args []string) { - if userFlagDeleteNow { + if userFlagDeleteNow && !userFlagDeleteConfirm { fmt.Println("You requested to delete the user immediately. Are you sure?") fmt.Println(`To confirm, please type "yes, I confirm" in all uppercase:`)