or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

advanced-prompts.mdclassic-api.mdconfirmation.mdindex.mdselection.mdtext-input.mdutilities.md

text-input.mddocs/

0

# Text Input Prompts

1

2

Basic text input capabilities for collecting user text, passwords, and file paths with extensive customization and validation options.

3

4

## Capabilities

5

6

### Text Input

7

8

General purpose text input prompt with support for multi-line input, auto-completion, and extensive validation.

9

10

```python { .api }

11

def text(

12

message: InquirerPyMessage,

13

default: InquirerPyDefault = "",

14

qmark: str = "?",

15

amark: str = "?",

16

instruction: str = "",

17

long_instruction: str = "",

18

completer: Optional[Union[Dict[str, Optional[str]], Completer]] = None,

19

multicolumn_complete: bool = False,

20

multiline: bool = False,

21

validate: Optional[InquirerPyValidate] = None,

22

invalid_message: str = "Invalid input",

23

transformer: Optional[Callable[[str], Any]] = None,

24

filter: Optional[Callable[[str], Any]] = None,

25

keybindings: Optional[InquirerPyKeybindings] = None,

26

wrap_lines: bool = True,

27

mandatory: bool = True,

28

mandatory_message: str = "Mandatory prompt",

29

style: Optional[InquirerPyStyle] = None,

30

vi_mode: bool = False,

31

raise_keyboard_interrupt: bool = True,

32

session_result: Optional[InquirerPySessionResult] = None,

33

**kwargs

34

) -> str

35

```

36

37

**Parameters:**

38

- **message**: The question text to display

39

- **default**: Default text value

40

- **qmark/amark**: Custom question/answer mark symbols

41

- **instruction/long_instruction**: Help text (short/detailed)

42

- **completer**: Auto-completion dictionary or Completer object

43

- **multicolumn_complete**: Enable multi-column completion display

44

- **multiline**: Allow multi-line input with Ctrl+J

45

- **validate**: Validation function or Validator object

46

- **invalid_message**: Error message for validation failures

47

- **transformer**: Function to transform display value

48

- **filter**: Function to transform result value

49

- **keybindings**: Custom keybinding overrides

50

- **wrap_lines**: Enable line wrapping

51

- **mandatory**: Require non-empty input when True

52

- **mandatory_message**: Error message for empty mandatory input

53

54

**Usage Example:**

55

```python

56

from InquirerPy import inquirer

57

58

# Basic text input

59

name = inquirer.text(message="Enter your name:").execute()

60

61

# With validation and default

62

email = inquirer.text(

63

message="Email address:",

64

default="user@example.com",

65

validate=lambda text: "@" in text,

66

invalid_message="Please enter a valid email"

67

).execute()

68

69

# Multi-line input

70

description = inquirer.text(

71

message="Description:",

72

multiline=True,

73

instruction="Press Ctrl+J for new line"

74

).execute()

75

```

76

77

### Secret Input

78

79

Password or secret input prompt that masks typed characters for secure input collection.

80

81

```python { .api }

82

def secret(

83

message: InquirerPyMessage,

84

default: InquirerPyDefault = "",

85

qmark: str = "?",

86

amark: str = "?",

87

instruction: str = "",

88

long_instruction: str = "",

89

validate: Optional[InquirerPyValidate] = None,

90

invalid_message: str = "Invalid input",

91

transformer: Optional[Callable[[str], Any]] = None,

92

filter: Optional[Callable[[str], Any]] = None,

93

keybindings: Optional[InquirerPyKeybindings] = None,

94

wrap_lines: bool = True,

95

mandatory: bool = True,

96

mandatory_message: str = "Mandatory prompt",

97

style: Optional[InquirerPyStyle] = None,

98

vi_mode: bool = False,

99

raise_keyboard_interrupt: bool = True,

100

session_result: Optional[InquirerPySessionResult] = None,

101

**kwargs

102

) -> str

103

```

104

105

**Usage Example:**

106

```python

107

from InquirerPy import inquirer

108

from InquirerPy.validator import PasswordValidator

109

110

# Basic password input

111

password = inquirer.secret(message="Enter password:").execute()

112

113

# With validation

114

secure_password = inquirer.secret(

115

message="Create password:",

116

validate=PasswordValidator(

117

length=8,

118

cap=True,

119

number=True,

120

special=True

121

),

122

invalid_message="Password must be 8+ chars with uppercase, number, and special character"

123

).execute()

124

```

125

126

### File Path Input

127

128

File or directory path input with auto-completion and path validation for cross-platform file selection.

129

130

```python { .api }

131

def filepath(

132

message: InquirerPyMessage,

133

default: InquirerPyDefault = "",

134

qmark: str = "?",

135

amark: str = "?",

136

instruction: str = "",

137

long_instruction: str = "",

138

multicolumn_complete: bool = False,

139

validate: Optional[InquirerPyValidate] = None,

140

invalid_message: str = "Invalid input",

141

only_directories: bool = False,

142

only_files: bool = False,

143

transformer: Optional[Callable[[str], Any]] = None,

144

filter: Optional[Callable[[str], Any]] = None,

145

keybindings: Optional[InquirerPyKeybindings] = None,

146

wrap_lines: bool = True,

147

mandatory: bool = True,

148

mandatory_message: str = "Mandatory prompt",

149

style: Optional[InquirerPyStyle] = None,

150

vi_mode: bool = False,

151

raise_keyboard_interrupt: bool = True,

152

session_result: Optional[InquirerPySessionResult] = None,

153

**kwargs

154

) -> str

155

```

156

157

**Parameters:**

158

- **only_directories**: Restrict to directories only

159

- **only_files**: Restrict to files only

160

161

**Usage Example:**

162

```python

163

from InquirerPy import inquirer

164

from InquirerPy.validator import PathValidator

165

166

# File selection with auto-completion

167

config_file = inquirer.filepath(

168

message="Select config file:",

169

default="./config.json",

170

only_files=True,

171

validate=PathValidator(is_file=True, message="File must exist")

172

).execute()

173

174

# Directory selection

175

output_dir = inquirer.filepath(

176

message="Choose output directory:",

177

only_directories=True,

178

validate=PathValidator(is_dir=True, message="Directory must exist")

179

).execute()

180

```

181

182

## Class-based Usage

183

184

Direct class instantiation for advanced customization:

185

186

```python

187

from InquirerPy.prompts import InputPrompt, SecretPrompt, FilePathPrompt

188

189

# InputPrompt class

190

prompt = InputPrompt(

191

message="Enter text:",

192

default="default value",

193

validate=lambda x: len(x) > 3,

194

transformer=lambda x: x.upper()

195

)

196

result = prompt.execute()

197

198

# SecretPrompt class

199

secret_prompt = SecretPrompt(

200

message="Password:",

201

validate=lambda x: len(x) >= 8

202

)

203

password = secret_prompt.execute()

204

205

# FilePathPrompt class

206

file_prompt = FilePathPrompt(

207

message="Select file:",

208

only_files=True

209

)

210

filepath = file_prompt.execute()

211

```