confirmop

package module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2023 License: MIT Imports: 2 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

ConfirmOperation prompts the user to confirm the operation and
returns false if the user enters "n" or "no" and true if the user enters "y" or "yes".
If the user enters an invalid option and retry is true, the user will be prompted
until they enter a valid option. If retry is false, the function will return false.

desc is a short description of the operation. Can be empty.
confirmText is the question that the user should answer. Defaults to "confirm" if empty string is passed.
retry determines if the user should be prompted repeatedly until they enter a valid option.

 example:

 import cop "github.com/jinyus/confirmop"

 userChoice := cop.ConfirmOperation("Do you want to delete this file","proceed",true)

 // The user will see this prompt:
 //   Do you want to delete this file
 //   proceed? (y/no): 

 if userChoice{
   //safe to delete file
  }

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfirmOperation

func ConfirmOperation(desc, confirmText string, retry bool, defaultChoice bool) bool

ConfirmOperation prompts the user to confirm the operation and returns false if the user enters "n" or "no" and true if the user enters "y" or "yes". If the user enters an invalid option and retry is true, the user will be prompted until they enter a valid option. If retry is false, the function will return false.

desc is a short description of the operation. Can be empty. confirmText is the question that the user should answer. Defaults to "confirm" if empty string is passed. retry determines if the user should be prompted repeatedly until they enter a valid option.

example: userChoice := ConfirmOperation("Do you want to delete this file","proceed",true)

if userChoice{
	//Safe to delete the file
}

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址