This repository has been archived by the owner on Apr 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added customisable hide character for password inputs. (#431)
Includes example, but is missing a test mend Co-authored-by: Alec Aivazis <alec@aivazis.com>
- Loading branch information
1 parent
734e799
commit d889203
Showing
3 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/AlecAivazis/survey/v2" | ||
) | ||
|
||
// the questions to ask | ||
var defaultPasswordCharacterPrompt = &survey.Password{ | ||
Message: "What is your password? (Default hide character)", | ||
} | ||
var customPasswordCharacterPrompt = &survey.Password{ | ||
Message: "What is your password? (Custom hide character)", | ||
} | ||
|
||
func main() { | ||
|
||
var defaultPass string | ||
var customPass string | ||
|
||
// ask the question | ||
err := survey.AskOne(defaultPasswordCharacterPrompt, &defaultPass) | ||
if err != nil { | ||
fmt.Println(err.Error()) | ||
return | ||
} | ||
fmt.Println() | ||
err = survey.AskOne(customPasswordCharacterPrompt, &customPass, survey.WithHideCharacter('-')) | ||
if err != nil { | ||
fmt.Println(err.Error()) | ||
return | ||
} | ||
// print the answers | ||
fmt.Printf("Password 1: %s.\n Password 2: %s\n", defaultPass, customPass) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters