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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
|
# Environment Variables
```{tip}
If you make calls to `InquirerPy` multiple times with a lot of customisation, you can consider utilising ENV variables.
```
Several options can be configured via ENV variables.
## Style
```{note}
Checkout {ref}`pages/style:Style` for more information about style customisation.
```
```{admonition} Priority
ENV -> `style` parameter -> default style
```
### Usage
<details>
<summary>Classic Syntax</summary>
```python
from InquirerPy import prompt
from InquirerPy import get_style
# before
result = prompt(questions=[{"type": "confirm", "message": "Confirm?"}], style={"questionmark": "#ffffff"})
# after
import os
os.environ["INQUIRERPY_STYLE_QUESTIONMARK"] = "#ffffff"
result = prompt(questions=[{"type": "confirm", "message": "Confirm?"}])
```
</details>
<details open>
<summary>Alternate Syntax</summary>
```python
from InquirerPy import inquirer
from InquirerPy import get_style
# before
result = inquirer.confirm(message="Confirm?", style=get_style({"questionmark": "#ffffff"})).execute()
# after
import os
os.environ["INQUIRERPY_STYLE_QUESTIONMARK"] = "#ffffff"
result = inquirer.confirm(message="Confirm?").execute()
```
</details>
### Mapping
| style class | ENV |
| ----------------- | ---------------------------------- |
| questionmark | INQUIRERPY_STYLE_QUESTIONMARK |
| answermark | INQUIRERPY_STYLE_ANSWERMARK |
| answer | INQUIRERPY_STYLE_ANSWER |
| input | INQUIRERPY_STYLE_INPUT |
| question | INQUIRERPY_STYLE_QUESTION |
| answered_question | INQUIRERPY_STYLE_ANSWERED_QUESTION |
| instruction | INQUIRERPY_STYLE_INSTRUCTION |
| pointer | INQUIRERPY_STYLE_POINTER |
| checkbox | INQUIRERPY_STYLE_CHECKBOX |
| separator | INQUIRERPY_STYLE_SEPARATOR |
| skipped | INQUIRERPY_STYLE_SKIPPED |
| validator | INQUIRERPY_STYLE_VALIDATOR |
| marker | INQUIRERPY_STYLE_MARKER |
| fuzzy_prompt | INQUIRERPY_STYLE_FUZZY_PROMPT |
| fuzzy_info | INQUIRERPY_STYLE_FUZZY_INFO |
| fuzzy_border | INQUIRERPY_STYLE_FUZZY_BORDER |
| fuzzy_match | INQUIRERPY_STYLE_FUZZY_MATCH |
| spinner_pattern | INQUIRERPY_STYLE_SPINNER_PATTERN |
| spinner_text | INQUIRERPY_STYLE_SPINNER_TEXT |
## Keybinding
```{note}
Checkout {ref}`pages/kb:Keybindings` for more information about customising keybindings.
```
```{admonition} Priority
ENV -> `vi_mode` parameter
```
### Usage
<details>
<summary>Classic Syntax</summary>
```python
from InquirerPy import prompt
# before
result = prompt(questions=[{"type": "input", "message": "Name:"}], vi_mode=True)
# after
import os
os.environ["INQUIRERPY_VI_MODE"] = "true"
result = prompt(questions=[{"type": "input", "message": "Name:"}])
```
</details>
<details open>
<summary>Alternate Syntax</summary>
```python
from InquirerPy import inquirer
# before
result = inquirer.text(message="Name:", vi_mode=True).execute()
# after
import os
os.environ["INQUIRERPY_VI_MODE"] = "true"
result = inquirer.text(message="Name").execute()
```
</details>
### Mapping
```{note}
The value of `INQUIRERPY_VI_MODE` does not matter, as long as its a string longer than 0, `InquirerPy` will set `vi_mode=True`.
```
| parameter | ENV |
| -------------- | ------------------ |
| `vi_mode=True` | INQUIRERPY_VI_MODE |
## Keyboard Interrupt
```{note}
Classic Syntax: Checkout {ref}`pages/prompt:Keyboard Interrupt` section for more information.
Alternate Syntax: Checkout {ref}`pages/inquirer:Keyboard Interrupt` section for more information.
```
```{admonition} Priority
ENV -> `raise_keyboard_interrupt` parameter
```
### Usage
<details>
<summary>Classic Syntax</summary>
```python
from InquirerPy import prompt
# before
result = prompt(questions=[{"type": "secret", "message": "Password:"}], raise_keyboard_interrupt=False)
# after
import os
os.environ["INQUIRERPY_NO_RAISE_KBI"] = "true"
result = prompt(questions=[{"type": "secret", "message": "Password:"}])
```
</details>
<details open>
<summary>Alternate Syntax</summary>
```python
from InquirerPy import inquirer
# before
result = inquirer.text(message="Name:", vi_mode=True).execute(raise_keyboard_interrupt=False)
# after
import os
os.environ["INQUIRERPY_NO_RAISE_KBI"] = "true"
result = inquirer.text(message="Name").execute()
```
</details>
### Mapping
```{note}
The value of `INQUIRERPY_NO_RAISE_KBI` does not matter, as long as its a string longer than 0,
InquirerPy will not raise {class}`KeyboardInterrupt` when user hit `ctrl-c`.
```
| parameter | ENV |
| -------------------------------- | ----------------------- |
| `raise_keyboard_interrupt=False` | INQUIRERPY_NO_RAISE_KBI |
|