1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
### interactive_textinput/demo

<details>
<summary>SHOW SOURCE</summary>
```go
package main
import (
"github.com/pterm/pterm"
)
func main() {
// Create an interactive text input with single line input mode and show it
result, _ := pterm.DefaultInteractiveTextInput.Show()
// Print a blank line for better readability
pterm.Println()
// Print the user's answer with an info prefix
pterm.Info.Printfln("You answered: %s", result)
}
```
</details>
### interactive_textinput/default-value

<details>
<summary>SHOW SOURCE</summary>
```go
package main
import (
"github.com/pterm/pterm"
)
func main() {
// Create an interactive text input with single line input mode and show it
result, _ := pterm.DefaultInteractiveTextInput.WithDefaultValue("Some default value").Show()
// Print a blank line for better readability
pterm.Println()
// Print the user's answer with an info prefix
pterm.Info.Printfln("You answered: %s", result)
}
```
</details>
### interactive_textinput/multi-line

<details>
<summary>SHOW SOURCE</summary>
```go
package main
import (
"github.com/pterm/pterm"
)
func main() {
// Create a default interactive text input with multi-line enabled.
// This allows the user to input multiple lines of text.
textInput := pterm.DefaultInteractiveTextInput.WithMultiLine()
// Show the text input to the user and store the result.
// The second return value (an error) is ignored with '_'.
result, _ := textInput.Show()
// Print a blank line for better readability in the output.
pterm.Println()
// Print the user's input prefixed with an informational message.
// The '%s' placeholder is replaced with the user's input.
pterm.Info.Printfln("You answered: %s", result)
}
```
</details>
### interactive_textinput/password

<details>
<summary>SHOW SOURCE</summary>
```go
package main
import "github.com/pterm/pterm"
func main() {
// Create an interactive text input with a mask for password input
passwordInput := pterm.DefaultInteractiveTextInput.WithMask("*")
// Show the password input prompt and store the result
result, _ := passwordInput.Show("Enter your password")
// Get the default logger from PTerm
logger := pterm.DefaultLogger
// Log the received password (masked)
// Note: In a real-world application, you should never log passwords
logger.Info("Password received", logger.Args("password", result))
}
```
</details>
|