Skip to content

Parameters

Parameters to our command line interface may be both CLI Options and CLI Arguments:

from typing import Annotated
import typer

app = typer.Typer()

@app.command()
def register(
    user: Annotated[str, typer.Argument()],
    age: Annotated[int, typer.Option(min=18)],
    score: Annotated[float, typer.Option(max=100)] = 0,
):
    print(f"User is {user}")
    print(f"--age is {age}")
    print(f"--score is {score}")

if __name__ == "__main__":
    app()

typer.Argument

Argument(
    default=...,
    *,
    callback=None,
    metavar=None,
    expose_value=True,
    is_eager=False,
    envvar=None,
    shell_complete=None,
    autocompletion=None,
    default_factory=None,
    parser=None,
    click_type=None,
    show_default=True,
    show_choices=True,
    show_envvar=True,
    help=None,
    hidden=False,
    case_sensitive=True,
    min=None,
    max=None,
    clamp=False,
    formats=None,
    mode=None,
    encoding=None,
    errors="strict",
    lazy=None,
    atomic=False,
    exists=False,
    file_okay=True,
    dir_okay=True,
    writable=False,
    readable=True,
    resolve_path=False,
    allow_dash=False,
    path_type=None,
    rich_help_panel=None,
)

A CLI Argument is a positional parameter to your command line application.

Often, CLI Arguments are required, meaning that users have to specify them. However, you can set them to be optional by defining a default value:

Example

@app.command()
def main(name: Annotated[str, typer.Argument()] = "World"):
    print(f"Hello {name}!")

Note how in this example, if name is not specified on the command line, the application will still execute normally and print "Hello World!".

PARAMETER DESCRIPTION
default

By default, CLI arguments are required. However, by giving them a default value they become optional:

Example

@app.command()
def main(name: str = typer.Argument("World")):
    print(f"Hello {name}!")

Note that this usage is deprecated, and we recommend to use Annotated instead:

@app.command()
def main(name: Annotated[str, typer.Argument()] = "World"):
    print(f"Hello {name}!")

TYPE: Optional[Any] DEFAULT: ...

callback

Add a callback to this CLI Argument, to execute additional logic with the value received from the terminal. See the tutorial about callbacks for more details.

Example

def name_callback(value: str):
    if value != "Deadpool":
        raise typer.BadParameter("Only Deadpool is allowed")
    return value

@app.command()
def main(name: Annotated[str, typer.Argument(callback=name_callback)]):
    print(f"Hello {name}")

TYPE: Optional[Callable[..., Any]] DEFAULT: None

metavar

Customize the name displayed in the help text to represent this CLI Argument. By default, it will be the same name you declared, in uppercase. See the tutorial about CLI Arguments with Help for more details.

Example

@app.command()
def main(name: Annotated[str, typer.Argument(metavar="✨username✨")]):
    print(f"Hello {name}")

TYPE: Optional[str] DEFAULT: None

expose_value

Note: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.


If this is True then the value is passed onwards to the command callback and stored on the context, otherwise it’s skipped.

TYPE: bool DEFAULT: True

is_eager

Set an argument to "eager" to ensure it gets processed before other CLI parameters. This could be relevant when there are other parameters with callbacks that could exit the program early. For more information and an extended example, see the documentation here.

TYPE: bool DEFAULT: False

envvar

Configure an argument to read a value from an environment variable if it is not provided in the command line as a CLI argument. For more information, see the documentation on Environment Variables.

Example

@app.command()
def main(name: Annotated[str, typer.Argument(envvar="ME")]):
    print(f"Hello Mr. {name}")

TYPE: Optional[Union[str, list[str]]] DEFAULT: None

shell_complete

Note: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility. It is however not fully functional, and will likely be removed in future versions.

TYPE: Optional[Callable[[Context, Parameter, str], Union[list[CompletionItem], list[str]]]] DEFAULT: None

autocompletion

Provide a custom function that helps to autocomplete the values of this CLI Argument. See the tutorial on parameter autocompletion for more details.

Example

def complete():
    return ["Me", "Myself", "I"]

@app.command()
def main(name: Annotated[str, typer.Argument(autocompletion=complete)]):
    print(f"Hello {name}")

TYPE: Optional[Callable[..., Any]] DEFAULT: None

default_factory

Provide a custom function that dynamically generates a default for this CLI Argument.

Example

def get_name():
    return random.choice(["Me", "Myself", "I"])

@app.command()
def main(name: Annotated[str, typer.Argument(default_factory=get_name)]):
    print(f"Hello {name}")

TYPE: Optional[Callable[[], Any]] DEFAULT: None

parser

Use your own custom types in Typer applications by defining a parser function that parses input into your own types:

Example

class CustomClass:
    def __init__(self, value: str):
        self.value = value

    def __str__(self):
        return f"<CustomClass: value={self.value}>"

def my_parser(value: str):
    return CustomClass(value * 2)

@app.command()
def main(arg: Annotated[CustomClass, typer.Argument(parser=my_parser):
    print(f"arg is {arg}")

TYPE: Optional[Callable[[str], Any]] DEFAULT: None

click_type

Define this parameter to use a custom Click type in your Typer applications.

Example

class MyClass:
    def __init__(self, value: str):
        self.value = value

    def __str__(self):
        return f"<MyClass: value={self.value}>"

class MyParser(click.ParamType):
    name = "MyClass"

    def convert(self, value, param, ctx):
        return MyClass(value * 3)

@app.command()
def main(arg: Annotated[MyClass, typer.Argument(click_type=MyParser())]):
    print(f"arg is {arg}")

TYPE: Optional[ParamType] DEFAULT: None

show_default

When set to False, don't show the default value of this CLI Argument in the help text.

Example

@app.command()
def main(name: Annotated[str, typer.Argument(show_default=False)] = "Rick"):
    print(f"Hello {name}")

TYPE: Union[bool, str] DEFAULT: True

show_choices

Note: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.


When set to False, this suppresses choices from being displayed inline when prompt is used.

TYPE: bool DEFAULT: True

show_envvar

When an "envvar" is defined, prevent it from showing up in the help text:

Example

@app.command()
def main(name: Annotated[str, typer.Argument(envvar="ME", show_envvar=False)]):
    print(f"Hello Mr. {name}")

TYPE: bool DEFAULT: True

help

Help text for this CLI Argument. See the tutorial about CLI Arguments with help for more dedails.

Example

@app.command()
def greet(name: Annotated[str, typer.Argument(help="Person to greet")]):
    print(f"Hello {name}")

TYPE: Optional[str] DEFAULT: None

hidden

Hide this CLI Argument from help outputs. False by default.

Example

@app.command()
def main(name: Annotated[str, typer.Argument(hidden=True)] = "World"):
    print(f"Hello {name}")

TYPE: bool DEFAULT: False

case_sensitive

For a CLI Argument representing an Enum (choice), you can allow case-insensitive matching with this parameter:

Example

from enum import Enum

class NeuralNetwork(str, Enum):
    simple = "simple"
    conv = "conv"
    lstm = "lstm"

@app.command()
def main(
    network: Annotated[NeuralNetwork, typer.Argument(case_sensitive=False)]):
    print(f"Training neural network of type: {network.value}")

With this setting, "LSTM" or "lstm" will both be valid values that will be resolved to NeuralNetwork.lstm.

TYPE: bool DEFAULT: True

min

For a CLI Argument representing a number (int or float), you can define numeric validations with min and max values:

Example

@app.command()
def main(
    user: Annotated[str, typer.Argument()],
    user_id: Annotated[int, typer.Argument(min=1, max=1000)],
):
    print(f"ID for {user} is {user_id}")

If the user attempts to input an invalid number, an error will be shown, explaining why the value is invalid.

TYPE: Optional[Union[int, float]] DEFAULT: None

max

For a CLI Argument representing a number (int or float), you can define numeric validations with min and max values:

Example

@app.command()
def main(
    user: Annotated[str, typer.Argument()],
    user_id: Annotated[int, typer.Argument(min=1, max=1000)],
):
    print(f"ID for {user} is {user_id}")

If the user attempts to input an invalid number, an error will be shown, explaining why the value is invalid.

TYPE: Optional[Union[int, float]] DEFAULT: None

clamp

For a CLI Argument representing a number and that is bounded by using min and/or max, you can opt to use the closest minimum or maximum value instead of raising an error. This is done by setting clamp to True.

Example

@app.command()
def main(
    user: Annotated[str, typer.Argument()],
    user_id: Annotated[int, typer.Argument(min=1, max=1000, clamp=True)],
):
    print(f"ID for {user} is {user_id}")

If the user attempts to input 3420 for user_id, this will internally be converted to 1000.

TYPE: bool DEFAULT: False

formats

For a CLI Argument representing a DateTime object, you can customize the formats that can be parsed automatically:

Example

from datetime import datetime

@app.command()
def main(
    birthday: Annotated[
        datetime,
        typer.Argument(
            formats=["%Y-%m-%d", "%Y-%m-%d %H:%M:%S", "%m/%d/%Y"]
        ),
    ],
):
    print(f"Birthday defined at: {birthday}")

TYPE: Optional[list[str]] DEFAULT: None

mode

For a CLI Argument representing a File object, you can customize the mode to open the file with. If unset, Typer will set a sensible value by default.

Example

@app.command()
def main(config: Annotated[typer.FileText, typer.Argument(mode="a")]):
    config.write("This is a single line\n")
    print("Config line written")

TYPE: Optional[str] DEFAULT: None

encoding

Customize the encoding of this CLI Argument represented by a File object.

Example

@app.command()
def main(config: Annotated[typer.FileText, typer.Argument(encoding="utf-8")]):
    config.write("All the text gets written\n")

TYPE: Optional[str] DEFAULT: None

errors

Note: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.


The error handling mode.

TYPE: Optional[str] DEFAULT: 'strict'

lazy

For a CLI Argument representing a File object, by default the file will not be created until you actually start writing to it. You can change this behaviour by setting this parameter. By default, it's set to True for writing and to False for reading.

Example

@app.command()
def main(config: Annotated[typer.FileText, typer.Argument(mode="a", lazy=False)]):
    config.write("This is a single line\n")
    print("Config line written")

TYPE: Optional[bool] DEFAULT: None

atomic

For a CLI Argument representing a File object, you can ensure that all write instructions first go into a temporal file, and are only moved to the final destination after completing by setting atomic to True. This can be useful for files with potential concurrent access.

Example

@app.command()
def main(config: Annotated[typer.FileText, typer.Argument(mode="a", atomic=True)]):
    config.write("All the text")

TYPE: bool DEFAULT: False

exists

When set to True for a Path argument, additional validation is performed to check that the file or directory exists. If not, the value will be invalid.

Example

from pathlib import Path

@app.command()
def main(config: Annotated[Path, typer.Argument(exists=True)]):
    text = config.read_text()
    print(f"Config file contents: {text}")

TYPE: bool DEFAULT: False

file_okay

Determine whether or not a Path argument is allowed to refer to a file. When this is set to False, the application will raise a validation error when a path to a file is given.

Example

from pathlib import Path

@app.command()
def main(config: Annotated[Path, typer.Argument(exists=True, file_okay=False)]):
    print(f"Directory listing: {[x.name for x in config.iterdir()]}")

TYPE: bool DEFAULT: True

dir_okay

Determine whether or not a Path argument is allowed to refer to a directory. When this is set to False, the application will raise a validation error when a path to a directory is given.

Example

from pathlib import Path

@app.command()
def main(config: Annotated[Path, typer.Argument(exists=True, dir_okay=False)]):
    text = config.read_text()
    print(f"Config file contents: {text}")

TYPE: bool DEFAULT: True

writable

Whether or not to perform a writable check for this Path argument.

Example

from pathlib import Path

@app.command()
def main(config: Annotated[Path, typer.Argument(writable=True)]):
    config.write_text("All the text")

TYPE: bool DEFAULT: False

readable

Whether or not to perform a readable check for this Path argument.

Example

from pathlib import Path

@app.command()
def main(config: Annotated[Path, typer.Argument(readable=True)]):
    config.read_text("All the text")

TYPE: bool DEFAULT: True

resolve_path

Whether or not to fully resolve the path of this Path argument, meaning that the path becomes absolute and symlinks are resolved.

Example

from pathlib import Path

@app.command()
def main(config: Annotated[Path, typer.Argument(resolve_path=True)]):
    config.read_text("All the text")

TYPE: bool DEFAULT: False

allow_dash

When set to True, a single dash for this Path argument would be a valid value, indicating standard streams. This is a more advanced use-case.

TYPE: bool DEFAULT: False

path_type

A string type that will be used to represent this Path argument. The default is None which means the return value will be either bytes or unicode, depending on what makes most sense given the input data. This is a more advanced use-case.

TYPE: Union[None, type[str], type[bytes]] DEFAULT: None

rich_help_panel

Set the panel name where you want this CLI Argument to be shown in the help text.

Example

@app.command()
def main(
    name: Annotated[str, typer.Argument(help="Who to greet")],
    age: Annotated[str, typer.Option(help="Their age", rich_help_panel="Data")],
):
    print(f"Hello {name} of age {age}")

TYPE: Union[str, None] DEFAULT: None

Source code in typer/params.py
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
def Argument(
    # Parameter
    default: Annotated[
        Optional[Any],
        Doc(
            """
            By default, CLI arguments are required. However, by giving them a default value they become [optional](https://typer.tiangolo.com/tutorial/arguments/optional):

            **Example**

            ```python
            @app.command()
            def main(name: str = typer.Argument("World")):
                print(f"Hello {name}!")
            ```

            Note that this usage is deprecated, and we recommend to use `Annotated` instead:
            ```python
            @app.command()
            def main(name: Annotated[str, typer.Argument()] = "World"):
                print(f"Hello {name}!")
            ```
            """
        ),
    ] = ...,
    *,
    callback: Annotated[
        Optional[Callable[..., Any]],
        Doc(
            """
            Add a callback to this CLI Argument, to execute additional logic with the value received from the terminal.
            See [the tutorial about callbacks](https://typer.tiangolo.com/tutorial/options/callback-and-context/) for more details.

            **Example**

            ```python
            def name_callback(value: str):
                if value != "Deadpool":
                    raise typer.BadParameter("Only Deadpool is allowed")
                return value

            @app.command()
            def main(name: Annotated[str, typer.Argument(callback=name_callback)]):
                print(f"Hello {name}")
            ```
            """
        ),
    ] = None,
    metavar: Annotated[
        Optional[str],
        Doc(
            """
            Customize the name displayed in the help text to represent this CLI Argument.
            By default, it will be the same name you declared, in uppercase.
            See [the tutorial about CLI Arguments with Help](https://typer.tiangolo.com/tutorial/arguments/help/#custom-help-name-metavar) for more details.

            **Example**

            ```python
            @app.command()
            def main(name: Annotated[str, typer.Argument(metavar="✨username✨")]):
                print(f"Hello {name}")
            ```
            """
        ),
    ] = None,
    expose_value: Annotated[
        bool,
        Doc(
            """
            **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.

            ---

            If this is `True` then the value is passed onwards to the command callback and stored on the context, otherwise it’s skipped.
            """
        ),
    ] = True,
    is_eager: Annotated[
        bool,
        Doc(
            """
            Set an argument to "eager" to ensure it gets processed before other CLI parameters. This could be relevant when there are other parameters with callbacks that could exit the program early.
            For more information and an extended example, see the documentation [here](https://typer.tiangolo.com/tutorial/options/version/#fix-with-is_eager).
            """
        ),
    ] = False,
    envvar: Annotated[
        Optional[Union[str, list[str]]],
        Doc(
            """
            Configure an argument to read a value from an environment variable if it is not provided in the command line as a CLI argument.
            For more information, see the [documentation on Environment Variables](https://typer.tiangolo.com/tutorial/arguments/envvar/).

            **Example**

            ```python
            @app.command()
            def main(name: Annotated[str, typer.Argument(envvar="ME")]):
                print(f"Hello Mr. {name}")
            ```
            """
        ),
    ] = None,
    # TODO: Remove shell_complete in a future version (after 0.16.0)
    shell_complete: Annotated[
        Optional[
            Callable[
                [click.Context, click.Parameter, str],
                Union[list["click.shell_completion.CompletionItem"], list[str]],
            ]
        ],
        Doc(
            """
            **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.
            It is however not fully functional, and will likely be removed in future versions.
            """
        ),
    ] = None,
    autocompletion: Annotated[
        Optional[Callable[..., Any]],
        Doc(
            """
            Provide a custom function that helps to autocomplete the values of this CLI Argument.
            See [the tutorial on parameter autocompletion](https://typer.tiangolo.com/tutorial/options-autocompletion) for more details.

            **Example**

            ```python
            def complete():
                return ["Me", "Myself", "I"]

            @app.command()
            def main(name: Annotated[str, typer.Argument(autocompletion=complete)]):
                print(f"Hello {name}")
            ```
            """
        ),
    ] = None,
    default_factory: Annotated[
        Optional[Callable[[], Any]],
        Doc(
            """
            Provide a custom function that dynamically generates a [default](https://typer.tiangolo.com/tutorial/arguments/default) for this CLI Argument.

            **Example**

            ```python
            def get_name():
                return random.choice(["Me", "Myself", "I"])

            @app.command()
            def main(name: Annotated[str, typer.Argument(default_factory=get_name)]):
                print(f"Hello {name}")
            ```
            """
        ),
    ] = None,
    # Custom type
    parser: Annotated[
        Optional[Callable[[str], Any]],
        Doc(
            """
            Use your own custom types in Typer applications by defining a `parser` function that parses input into your own types:

            **Example**

            ```python
            class CustomClass:
                def __init__(self, value: str):
                    self.value = value

                def __str__(self):
                    return f"<CustomClass: value={self.value}>"

            def my_parser(value: str):
                return CustomClass(value * 2)

            @app.command()
            def main(arg: Annotated[CustomClass, typer.Argument(parser=my_parser):
                print(f"arg is {arg}")
            ```
            """
        ),
    ] = None,
    click_type: Annotated[
        Optional[click.ParamType],
        Doc(
            """
            Define this parameter to use a [custom Click type](https://click.palletsprojects.com/en/stable/parameters/#implementing-custom-types) in your Typer applications.

            **Example**

            ```python
            class MyClass:
                def __init__(self, value: str):
                    self.value = value

                def __str__(self):
                    return f"<MyClass: value={self.value}>"

            class MyParser(click.ParamType):
                name = "MyClass"

                def convert(self, value, param, ctx):
                    return MyClass(value * 3)

            @app.command()
            def main(arg: Annotated[MyClass, typer.Argument(click_type=MyParser())]):
                print(f"arg is {arg}")
            ```
            """
        ),
    ] = None,
    # TyperArgument
    show_default: Annotated[
        Union[bool, str],
        Doc(
            """
            When set to `False`, don't show the default value of this CLI Argument in the [help text](https://typer.tiangolo.com/tutorial/arguments/help/).

            **Example**

            ```python
            @app.command()
            def main(name: Annotated[str, typer.Argument(show_default=False)] = "Rick"):
                print(f"Hello {name}")
            ```
            """
        ),
    ] = True,
    show_choices: Annotated[
        bool,
        Doc(
            """
            **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.

            ---

            When set to `False`, this suppresses choices from being displayed inline when `prompt` is used.
            """
        ),
    ] = True,
    show_envvar: Annotated[
        bool,
        Doc(
            """
            When an ["envvar"](https://typer.tiangolo.com/tutorial/arguments/envvar) is defined, prevent it from showing up in the help text:

            **Example**

            ```python
            @app.command()
            def main(name: Annotated[str, typer.Argument(envvar="ME", show_envvar=False)]):
                print(f"Hello Mr. {name}")
            ```
            """
        ),
    ] = True,
    help: Annotated[
        Optional[str],
        Doc(
            """
            Help text for this CLI Argument.
            See [the tutorial about CLI Arguments with help](https://typer.tiangolo.com/tutorial/arguments/help/) for more dedails.

            **Example**

            ```python
            @app.command()
            def greet(name: Annotated[str, typer.Argument(help="Person to greet")]):
                print(f"Hello {name}")
            ```
            """
        ),
    ] = None,
    hidden: Annotated[
        bool,
        Doc(
            """
            Hide this CLI Argument from [help outputs](https://typer.tiangolo.com/tutorial/arguments/help). `False` by default.

            **Example**

            ```python
            @app.command()
            def main(name: Annotated[str, typer.Argument(hidden=True)] = "World"):
                print(f"Hello {name}")
            ```
            """
        ),
    ] = False,
    # Choice
    case_sensitive: Annotated[
        bool,
        Doc(
            """
            For a CLI Argument representing an [Enum (choice)](https://typer.tiangolo.com/tutorial/parameter-types/enum),
            you can allow case-insensitive matching with this parameter:

            **Example**

            ```python
            from enum import Enum

            class NeuralNetwork(str, Enum):
                simple = "simple"
                conv = "conv"
                lstm = "lstm"

            @app.command()
            def main(
                network: Annotated[NeuralNetwork, typer.Argument(case_sensitive=False)]):
                print(f"Training neural network of type: {network.value}")
            ```

            With this setting, "LSTM" or "lstm" will both be valid values that will be resolved to `NeuralNetwork.lstm`.
            """
        ),
    ] = True,
    # Numbers
    min: Annotated[
        Optional[Union[int, float]],
        Doc(
            """
            For a CLI Argument representing a [number](https://typer.tiangolo.com/tutorial/parameter-types/number/) (`int` or `float`),
            you can define numeric validations with `min` and `max` values:

            **Example**

            ```python
            @app.command()
            def main(
                user: Annotated[str, typer.Argument()],
                user_id: Annotated[int, typer.Argument(min=1, max=1000)],
            ):
                print(f"ID for {user} is {user_id}")
            ```

            If the user attempts to input an invalid number, an error will be shown, explaining why the value is invalid.
            """
        ),
    ] = None,
    max: Annotated[
        Optional[Union[int, float]],
        Doc(
            """
            For a CLI Argument representing a [number](https://typer.tiangolo.com/tutorial/parameter-types/number/) (`int` or `float`),
            you can define numeric validations with `min` and `max` values:

            **Example**

            ```python
            @app.command()
            def main(
                user: Annotated[str, typer.Argument()],
                user_id: Annotated[int, typer.Argument(min=1, max=1000)],
            ):
                print(f"ID for {user} is {user_id}")
            ```

            If the user attempts to input an invalid number, an error will be shown, explaining why the value is invalid.
            """
        ),
    ] = None,
    clamp: Annotated[
        bool,
        Doc(
            """
            For a CLI Argument representing a [number](https://typer.tiangolo.com/tutorial/parameter-types/number/) and that is bounded by using `min` and/or `max`,
            you can opt to use the closest minimum or maximum value instead of raising an error. This is done by setting `clamp` to `True`.

            **Example**

            ```python
            @app.command()
            def main(
                user: Annotated[str, typer.Argument()],
                user_id: Annotated[int, typer.Argument(min=1, max=1000, clamp=True)],
            ):
                print(f"ID for {user} is {user_id}")
            ```

            If the user attempts to input 3420 for `user_id`, this will internally be converted to `1000`.
            """
        ),
    ] = False,
    # DateTime
    formats: Annotated[
        Optional[list[str]],
        Doc(
            """
            For a CLI Argument representing a [DateTime object](https://typer.tiangolo.com/tutorial/parameter-types/datetime),
            you can customize the formats that can be parsed automatically:

            **Example**

            ```python
            from datetime import datetime

            @app.command()
            def main(
                birthday: Annotated[
                    datetime,
                    typer.Argument(
                        formats=["%Y-%m-%d", "%Y-%m-%d %H:%M:%S", "%m/%d/%Y"]
                    ),
                ],
            ):
                print(f"Birthday defined at: {birthday}")
            ```
            """
        ),
    ] = None,
    # File
    mode: Annotated[
        Optional[str],
        Doc(
            """
            For a CLI Argument representing a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/),
            you can customize the mode to open the file with. If unset, Typer will set a [sensible value by default](https://typer.tiangolo.com/tutorial/parameter-types/file/#advanced-mode).

            **Example**

            ```python
            @app.command()
            def main(config: Annotated[typer.FileText, typer.Argument(mode="a")]):
                config.write("This is a single line\\n")
                print("Config line written")
            ```
            """
        ),
    ] = None,
    encoding: Annotated[
        Optional[str],
        Doc(
            """
            Customize the encoding of this CLI Argument represented by a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/).

            **Example**

            ```python
            @app.command()
            def main(config: Annotated[typer.FileText, typer.Argument(encoding="utf-8")]):
                config.write("All the text gets written\\n")
            ```
            """
        ),
    ] = None,
    errors: Annotated[
        Optional[str],
        Doc(
            """
            **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.

            ---

            The error handling mode.
            """
        ),
    ] = "strict",
    lazy: Annotated[
        Optional[bool],
        Doc(
            """
            For a CLI Argument representing a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/),
            by default the file will not be created until you actually start writing to it.
            You can change this behaviour by setting this parameter.
            By default, it's set to `True` for writing and to `False` for reading.

            **Example**

            ```python
            @app.command()
            def main(config: Annotated[typer.FileText, typer.Argument(mode="a", lazy=False)]):
                config.write("This is a single line\\n")
                print("Config line written")
            ```
            """
        ),
    ] = None,
    atomic: Annotated[
        bool,
        Doc(
            """
            For a CLI Argument representing a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/),
            you can ensure that all write instructions first go into a temporal file, and are only moved to the final destination after completing
            by setting `atomic` to `True`. This can be useful for files with potential concurrent access.

            **Example**

            ```python
            @app.command()
            def main(config: Annotated[typer.FileText, typer.Argument(mode="a", atomic=True)]):
                config.write("All the text")
            ```
            """
        ),
    ] = False,
    # Path
    exists: Annotated[
        bool,
        Doc(
            """
            When set to `True` for a [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/),
            additional validation is performed to check that the file or directory exists. If not, the value will be invalid.

            **Example**

            ```python
            from pathlib import Path

            @app.command()
            def main(config: Annotated[Path, typer.Argument(exists=True)]):
                text = config.read_text()
                print(f"Config file contents: {text}")
            ```
            """
        ),
    ] = False,
    file_okay: Annotated[
        bool,
        Doc(
            """
            Determine whether or not a [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/)
            is allowed to refer to a file. When this is set to `False`, the application will raise a validation error when a path to a file is given.

            **Example**

            ```python
            from pathlib import Path

            @app.command()
            def main(config: Annotated[Path, typer.Argument(exists=True, file_okay=False)]):
                print(f"Directory listing: {[x.name for x in config.iterdir()]}")
            ```
            """
        ),
    ] = True,
    dir_okay: Annotated[
        bool,
        Doc(
            """
            Determine whether or not a [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/)
            is allowed to refer to a directory. When this is set to `False`, the application will raise a validation error when a path to a directory is given.

            **Example**

            ```python
            from pathlib import Path

            @app.command()
            def main(config: Annotated[Path, typer.Argument(exists=True, dir_okay=False)]):
                text = config.read_text()
                print(f"Config file contents: {text}")
            ```
            """
        ),
    ] = True,
    writable: Annotated[
        bool,
        Doc(
            """
            Whether or not to perform a writable check for this [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/).

            **Example**

            ```python
            from pathlib import Path

            @app.command()
            def main(config: Annotated[Path, typer.Argument(writable=True)]):
                config.write_text("All the text")
            ```
            """
        ),
    ] = False,
    readable: Annotated[
        bool,
        Doc(
            """
            Whether or not to perform a readable check for this [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/).

            **Example**

            ```python
            from pathlib import Path

            @app.command()
            def main(config: Annotated[Path, typer.Argument(readable=True)]):
                config.read_text("All the text")
            ```
            """
        ),
    ] = True,
    resolve_path: Annotated[
        bool,
        Doc(
            """
            Whether or not to fully resolve the path of this [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/),
            meaning that the path becomes absolute and symlinks are resolved.

            **Example**

            ```python
            from pathlib import Path

            @app.command()
            def main(config: Annotated[Path, typer.Argument(resolve_path=True)]):
                config.read_text("All the text")
            ```
            """
        ),
    ] = False,
    allow_dash: Annotated[
        bool,
        Doc(
            """
            When set to `True`, a single dash for this [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/)
            would be a valid value, indicating standard streams. This is a more advanced use-case.
            """
        ),
    ] = False,
    path_type: Annotated[
        Union[None, type[str], type[bytes]],
        Doc(
            """
            A string type that will be used to represent this [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/).
            The default is `None` which means the return value will be either bytes or unicode, depending on what makes most sense given the input data.
            This is a more advanced use-case.
            """
        ),
    ] = None,
    # Rich settings
    rich_help_panel: Annotated[
        Union[str, None],
        Doc(
            """
            Set the panel name where you want this CLI Argument to be shown in the [help text](https://typer.tiangolo.com/tutorial/arguments/help).

            **Example**

            ```python
            @app.command()
            def main(
                name: Annotated[str, typer.Argument(help="Who to greet")],
                age: Annotated[str, typer.Option(help="Their age", rich_help_panel="Data")],
            ):
                print(f"Hello {name} of age {age}")
            ```
            """
        ),
    ] = None,
) -> Any:
    """
    A [CLI Argument](https://typer.tiangolo.com/tutorial/arguments) is a positional parameter to your command line application.

    Often, CLI Arguments are required, meaning that users have to specify them. However, you can set them to be optional by defining a default value:

    ## Example

    ```python
    @app.command()
    def main(name: Annotated[str, typer.Argument()] = "World"):
        print(f"Hello {name}!")
    ```

    Note how in this example, if `name` is not specified on the command line, the application will still execute normally and print "Hello World!".
    """
    return ArgumentInfo(
        # Parameter
        default=default,
        # Arguments can only have one param declaration
        # it will be generated from the param name
        param_decls=None,
        callback=callback,
        metavar=metavar,
        expose_value=expose_value,
        is_eager=is_eager,
        envvar=envvar,
        shell_complete=shell_complete,
        autocompletion=autocompletion,
        default_factory=default_factory,
        # Custom type
        parser=parser,
        click_type=click_type,
        # TyperArgument
        show_default=show_default,
        show_choices=show_choices,
        show_envvar=show_envvar,
        help=help,
        hidden=hidden,
        # Choice
        case_sensitive=case_sensitive,
        # Numbers
        min=min,
        max=max,
        clamp=clamp,
        # DateTime
        formats=formats,
        # File
        mode=mode,
        encoding=encoding,
        errors=errors,
        lazy=lazy,
        atomic=atomic,
        # Path
        exists=exists,
        file_okay=file_okay,
        dir_okay=dir_okay,
        writable=writable,
        readable=readable,
        resolve_path=resolve_path,
        allow_dash=allow_dash,
        path_type=path_type,
        # Rich settings
        rich_help_panel=rich_help_panel,
    )

typer.Option

Option(
    default=...,
    *param_decls,
    callback=None,
    metavar=None,
    expose_value=True,
    is_eager=False,
    envvar=None,
    shell_complete=None,
    autocompletion=None,
    default_factory=None,
    parser=None,
    click_type=None,
    show_default=True,
    prompt=False,
    confirmation_prompt=False,
    prompt_required=True,
    hide_input=False,
    is_flag=None,
    flag_value=None,
    count=False,
    allow_from_autoenv=True,
    help=None,
    hidden=False,
    show_choices=True,
    show_envvar=True,
    case_sensitive=True,
    min=None,
    max=None,
    clamp=False,
    formats=None,
    mode=None,
    encoding=None,
    errors="strict",
    lazy=None,
    atomic=False,
    exists=False,
    file_okay=True,
    dir_okay=True,
    writable=False,
    readable=True,
    resolve_path=False,
    allow_dash=False,
    path_type=None,
    rich_help_panel=None,
)

A CLI Option is a parameter to your command line application that is called with a single or double dash, something like --verbose or -v.

Often, CLI Options are optional, meaning that users can omit them from the command. However, you can set them to be required by using Annotated and omitting a default value.

Example

@app.command()
def register(
    user: Annotated[str, typer.Argument()],
    age: Annotated[int, typer.Option(min=18)],
):
    print(f"User is {user}")
    print(f"--age is {age}")

Note how in this example, --age is a required CLI Option.

PARAMETER DESCRIPTION
default

Usually, CLI options are optional and have a default value, passed on like this:

Example

@app.command()
def main(network: str = typer.Option("CNN")):
    print(f"Training neural network of type: {network}")

Note that this usage is deprecated, and we recommend to use Annotated instead:

@app.command()
def main(network: Annotated[str, typer.Option()] = "CNN"):
    print(f"Hello {name}!")

You can also use ... (Ellipsis) as the "default" value to clarify that this is a required CLI option.

TYPE: Optional[Any] DEFAULT: ...

*param_decls

Positional argument that defines how users can call this option on the command line. This may be one or multiple aliases, all strings. If not defined, Typer will automatically use the function parameter as default name. See the tutorial about CLI Option Names for more details.

Example

@app.command()
def main(user_name: Annotated[str, typer.Option("--user", "-u", "-x")]):
    print(f"Hello {user_name}")

TYPE: str DEFAULT: ()

callback

Add a callback to this CLI Option, to execute additional logic after its value was received from the terminal. See the tutorial about callbacks for more details.

Example

def name_callback(value: str):
    if value != "Deadpool":
        raise typer.BadParameter("Only Deadpool is allowed")
    return value

@app.command()
def main(name: Annotated[str, typer.Option(callback=name_callback)]):
    print(f"Hello {name}")

TYPE: Optional[Callable[..., Any]] DEFAULT: None

metavar

Customize the name displayed in the help text to represent this CLI option. Note that this doesn't influence the way the option must be called.

Example

@app.command()
def main(user: Annotated[str, typer.Option(metavar="User name")]):
    print(f"Hello {user}")

TYPE: Optional[str] DEFAULT: None

expose_value

Note: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.


If this is True then the value is passed onwards to the command callback and stored on the context, otherwise it’s skipped.

TYPE: bool DEFAULT: True

is_eager

Mark a CLI Option to be "eager", ensuring it gets processed before other CLI parameters. This could be relevant when there are other parameters with callbacks that could exit the program early. For more information and an extended example, see the documentation here.

TYPE: bool DEFAULT: False

envvar

Configure a CLI Option to read its value from an environment variable if it is not provided in the command line. For more information, see the documentation on Environment Variables.

Example

@app.command()
def main(user: Annotated[str, typer.Option(envvar="ME")]):
    print(f"Hello {user}")

TYPE: Optional[Union[str, list[str]]] DEFAULT: None

shell_complete

Note: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility. It is however not fully functional, and will likely be removed in future versions.

TYPE: Optional[Callable[[Context, Parameter, str], Union[list[CompletionItem], list[str]]]] DEFAULT: None

autocompletion

Provide a custom function that helps to autocomplete the values of this CLI Option. See the tutorial on parameter autocompletion for more details.

Example

def complete():
    return ["Me", "Myself", "I"]

@app.command()
def main(name: Annotated[str, typer.Option(autocompletion=complete)]):
    print(f"Hello {name}")

TYPE: Optional[Callable[..., Any]] DEFAULT: None

default_factory

Provide a custom function that dynamically generates a default for this CLI Option.

Example

def get_name():
    return random.choice(["Me", "Myself", "I"])

@app.command()
def main(name: Annotated[str, typer.Option(default_factory=get_name)]):
    print(f"Hello {name}")

TYPE: Optional[Callable[[], Any]] DEFAULT: None

parser

Use your own custom types in Typer applications by defining a parser function that parses input into your own types:

Example

class CustomClass:
    def __init__(self, value: str):
        self.value = value

    def __str__(self):
        return f"<CustomClass: value={self.value}>"

def my_parser(value: str):
    return CustomClass(value * 2)

@app.command()
def main(opt: Annotated[CustomClass, typer.Option(parser=my_parser)] = "Foo"):
    print(f"--opt is {opt}")

TYPE: Optional[Callable[[str], Any]] DEFAULT: None

click_type

Define this parameter to use a custom Click type in your Typer applications.

Example

class MyClass:
    def __init__(self, value: str):
        self.value = value

    def __str__(self):
        return f"<MyClass: value={self.value}>"

class MyParser(click.ParamType):
    name = "MyClass"

    def convert(self, value, param, ctx):
        return MyClass(value * 3)

@app.command()
def main(opt: Annotated[MyClass, typer.Option(click_type=MyParser())] = "Foo"):
    print(f"--opt is {opt}")

TYPE: Optional[ParamType] DEFAULT: None

show_default

When set to False, don't show the default value of this CLI Option in the help text.

Example

@app.command()
def main(name: Annotated[str, typer.Option(show_default=False)] = "Rick"):
    print(f"Hello {name}")

TYPE: Union[bool, str] DEFAULT: True

prompt

When set to True, a prompt will appear to ask for the value of this CLI Option if it was not provided:

Example

@app.command()
def main(name: str, lastname: Annotated[str, typer.Option(prompt=True)]):
    print(f"Hello {name} {lastname}")

TYPE: Union[bool, str] DEFAULT: False

confirmation_prompt

When set to True, a user will need to type a prompted value twice (may be useful for passwords etc.).

Example

@app.command()
def main(project: Annotated[str, typer.Option(prompt=True, confirmation_prompt=True)]):
    print(f"Deleting project {project}")

TYPE: bool DEFAULT: False

prompt_required

Note: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.


If this is False then a prompt is only shown if the option's flag is given without a value.

TYPE: bool DEFAULT: True

hide_input

When you've configured a prompt, for instance for querying a password, don't show anything on the screen while the user is typing the value.

Example

@app.command()
def login(
    name: str,
    password: Annotated[str, typer.Option(prompt=True, hide_input=True)],
):
    print(f"Hello {name}. Doing something very secure with password.")

TYPE: bool DEFAULT: False

is_flag

Note: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility. It is however not fully functional, and will likely be removed in future versions.

TYPE: Optional[bool] DEFAULT: None

flag_value

Note: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility. It is however not fully functional, and will likely be removed in future versions.

TYPE: Optional[Any] DEFAULT: None

count

Make a CLI Option work as a counter. The CLI option will have the int value representing the number of times the option was used on the command line.

Example

@app.command()
def main(verbose: Annotated[int, typer.Option("--verbose", "-v", count=True)] = 0):
    print(f"Verbose level is {verbose}")

TYPE: bool DEFAULT: False

allow_from_autoenv

Note: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.


If this is enabled then the value of this parameter will be pulled from an environment variable in case a prefix is defined on the context.

TYPE: bool DEFAULT: True

help

Help text for this CLI Option. See the tutorial about CLI Options with help for more dedails.

Example

@app.command()
def greet(name: Annotated[str, typer.Option(help="Person to greet")] = "Deadpool"):
    print(f"Hello {name}")

TYPE: Optional[str] DEFAULT: None

hidden

Hide this CLI Option from help outputs. False by default.

Example

@app.command()
def greet(name: Annotated[str, typer.Option(hidden=True)] = "Deadpool"):
    print(f"Hello {name}")

TYPE: bool DEFAULT: False

show_choices

Note: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.


When set to False, this suppresses choices from being displayed inline when prompt is used.

TYPE: bool DEFAULT: True

show_envvar

When an "envvar" is defined, prevent it from showing up in the help text:

Example

@app.command()
def main(user: Annotated[str, typer.Option(envvar="ME", show_envvar=False)]):
    print(f"Hello {user}")

TYPE: bool DEFAULT: True

case_sensitive

For a CLI Option representing an Enum (choice), you can allow case-insensitive matching with this parameter:

Example

from enum import Enum

class NeuralNetwork(str, Enum):
    simple = "simple"
    conv = "conv"
    lstm = "lstm"

@app.command()
def main(
    network: Annotated[NeuralNetwork, typer.Option(case_sensitive=False)]):
    print(f"Training neural network of type: {network.value}")

With this setting, "LSTM" or "lstm" will both be valid values that will be resolved to NeuralNetwork.lstm.

TYPE: bool DEFAULT: True

min

For a CLI Option representing a number (int or float), you can define numeric validations with min and max values:

Example

@app.command()
def main(
    user: Annotated[str, typer.Argument()],
    user_id: Annotated[int, typer.Option(min=1, max=1000)],
):
    print(f"ID for {user} is {user_id}")

If the user attempts to input an invalid number, an error will be shown, explaining why the value is invalid.

TYPE: Optional[Union[int, float]] DEFAULT: None

max

For a CLI Option representing a number (int or float), you can define numeric validations with min and max values:

Example

@app.command()
def main(
    user: Annotated[str, typer.Argument()],
    user_id: Annotated[int, typer.Option(min=1, max=1000)],
):
    print(f"ID for {user} is {user_id}")

If the user attempts to input an invalid number, an error will be shown, explaining why the value is invalid.

TYPE: Optional[Union[int, float]] DEFAULT: None

clamp

For a CLI Option representing a number and that is bounded by using min and/or max, you can opt to use the closest minimum or maximum value instead of raising an error when the value is out of bounds. This is done by setting clamp to True.

Example

@app.command()
def main(
    user: Annotated[str, typer.Argument()],
    user_id: Annotated[int, typer.Option(min=1, max=1000, clamp=True)],
):
    print(f"ID for {user} is {user_id}")

If the user attempts to input 3420 for user_id, this will internally be converted to 1000.

TYPE: bool DEFAULT: False

formats

For a CLI Option representing a DateTime object, you can customize the formats that can be parsed automatically:

Example

from datetime import datetime

@app.command()
def main(
    birthday: Annotated[
        datetime,
        typer.Option(
            formats=["%Y-%m-%d", "%Y-%m-%d %H:%M:%S", "%m/%d/%Y"]
        ),
    ],
):
    print(f"Birthday defined at: {birthday}")

TYPE: Optional[list[str]] DEFAULT: None

mode

For a CLI Option representing a File object, you can customize the mode to open the file with. If unset, Typer will set a sensible value by default.

Example

@app.command()
def main(config: Annotated[typer.FileText, typer.Option(mode="a")]):
    config.write("This is a single line\n")
    print("Config line written")

TYPE: Optional[str] DEFAULT: None

encoding

Customize the encoding of this CLI Option represented by a File object.

Example

@app.command()
def main(config: Annotated[typer.FileText, typer.Option(encoding="utf-8")]):
    config.write("All the text gets written\n")

TYPE: Optional[str] DEFAULT: None

errors

Note: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.


The error handling mode.

TYPE: Optional[str] DEFAULT: 'strict'

lazy

For a CLI Option representing a File object, by default the file will not be created until you actually start writing to it. You can change this behaviour by setting this parameter. By default, it's set to True for writing and to False for reading.

Example

@app.command()
def main(config: Annotated[typer.FileText, typer.Option(mode="a", lazy=False)]):
    config.write("This is a single line\n")
    print("Config line written")

TYPE: Optional[bool] DEFAULT: None

atomic

For a CLI Option representing a File object, you can ensure that all write instructions first go into a temporal file, and are only moved to the final destination after completing by setting atomic to True. This can be useful for files with potential concurrent access.

Example

@app.command()
def main(config: Annotated[typer.FileText, typer.Option(mode="a", atomic=True)]):
    config.write("All the text")

TYPE: bool DEFAULT: False

exists

When set to True for a Path CLI Option, additional validation is performed to check that the file or directory exists. If not, the value will be invalid.

Example

from pathlib import Path

@app.command()
def main(config: Annotated[Path, typer.Option(exists=True)]):
    text = config.read_text()
    print(f"Config file contents: {text}")

TYPE: bool DEFAULT: False

file_okay

Determine whether or not a Path CLI Option is allowed to refer to a file. When this is set to False, the application will raise a validation error when a path to a file is given.

Example

from pathlib import Path

@app.command()
def main(config: Annotated[Path, typer.Option(exists=True, file_okay=False)]):
    print(f"Directory listing: {[x.name for x in config.iterdir()]}")

TYPE: bool DEFAULT: True

dir_okay

Determine whether or not a Path CLI Option is allowed to refer to a directory. When this is set to False, the application will raise a validation error when a path to a directory is given.

Example

from pathlib import Path

@app.command()
def main(config: Annotated[Path, typer.Argument(exists=True, dir_okay=False)]):
    text = config.read_text()
    print(f"Config file contents: {text}")

TYPE: bool DEFAULT: True

writable

Whether or not to perform a writable check for this Path CLI Option.

Example

from pathlib import Path

@app.command()
def main(config: Annotated[Path, typer.Option(writable=True)]):
    config.write_text("All the text")

TYPE: bool DEFAULT: False

readable

Whether or not to perform a readable check for this Path CLI Option.

Example

from pathlib import Path

@app.command()
def main(config: Annotated[Path, typer.Option(readable=True)]):
    config.read_text("All the text")

TYPE: bool DEFAULT: True

resolve_path

Whether or not to fully resolve the path of this Path CLI Option, meaning that the path becomes absolute and symlinks are resolved.

Example

from pathlib import Path

@app.command()
def main(config: Annotated[Path, typer.Option(resolve_path=True)]):
    config.read_text("All the text")

TYPE: bool DEFAULT: False

allow_dash

When set to True, a single dash for this Path CLI Option would be a valid value, indicating standard streams. This is a more advanced use-case.

TYPE: bool DEFAULT: False

path_type

A string type that will be used to represent this Path argument. The default is None which means the return value will be either bytes or unicode, depending on what makes most sense given the input data. This is a more advanced use-case.

TYPE: Union[None, type[str], type[bytes]] DEFAULT: None

rich_help_panel

Set the panel name where you want this CLI Option to be shown in the help text.

Example

@app.command()
def main(
    name: Annotated[str, typer.Argument(help="Who to greet")],
    age: Annotated[str, typer.Option(help="Their age", rich_help_panel="Data")],
):
    print(f"Hello {name} of age {age}")

TYPE: Union[str, None] DEFAULT: None

Source code in typer/params.py
 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
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
def Option(
    # Parameter
    default: Annotated[
        Optional[Any],
        Doc(
            """
            Usually, [CLI options](https://typer.tiangolo.com/tutorial/options/) are optional and have a default value, passed on like this:

            **Example**

            ```python
            @app.command()
            def main(network: str = typer.Option("CNN")):
                print(f"Training neural network of type: {network}")
            ```

            Note that this usage is deprecated, and we recommend to use `Annotated` instead:
            ```
            @app.command()
            def main(network: Annotated[str, typer.Option()] = "CNN"):
                print(f"Hello {name}!")
            ```

            You can also use `...` ([Ellipsis](https://docs.python.org/3/library/constants.html#Ellipsis)) as the "default" value to clarify that this is a required CLI option.
            """
        ),
    ] = ...,
    *param_decls: Annotated[
        str,
        Doc(
            """
            Positional argument that defines how users can call this option on the command line. This may be one or multiple aliases, all strings.
            If not defined, Typer will automatically use the function parameter as default name.
            See [the tutorial about CLI Option Names](https://typer.tiangolo.com/tutorial/options/name/) for more details.

            **Example**

            ```python
            @app.command()
            def main(user_name: Annotated[str, typer.Option("--user", "-u", "-x")]):
                print(f"Hello {user_name}")
            ```
            """
        ),
    ],
    callback: Annotated[
        Optional[Callable[..., Any]],
        Doc(
            """
            Add a callback to this CLI Option, to execute additional logic after its value was received from the terminal.
            See [the tutorial about callbacks](https://typer.tiangolo.com/tutorial/options/callback-and-context/) for more details.

            **Example**

            ```python
            def name_callback(value: str):
                if value != "Deadpool":
                    raise typer.BadParameter("Only Deadpool is allowed")
                return value

            @app.command()
            def main(name: Annotated[str, typer.Option(callback=name_callback)]):
                print(f"Hello {name}")
            ```
            """
        ),
    ] = None,
    metavar: Annotated[
        Optional[str],
        Doc(
            """
            Customize the name displayed in the [help text](https://typer.tiangolo.com/tutorial/options/help/) to represent this CLI option.
            Note that this doesn't influence the way the option must be called.

            **Example**

            ```python
            @app.command()
            def main(user: Annotated[str, typer.Option(metavar="User name")]):
                print(f"Hello {user}")
            ```
            """
        ),
    ] = None,
    expose_value: Annotated[
        bool,
        Doc(
            """
            **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.

            ---

            If this is `True` then the value is passed onwards to the command callback and stored on the context, otherwise it’s skipped.
            """
        ),
    ] = True,
    is_eager: Annotated[
        bool,
        Doc(
            """
            Mark a CLI Option to be "eager", ensuring it gets processed before other CLI parameters. This could be relevant when there are other parameters with callbacks that could exit the program early.
            For more information and an extended example, see the documentation [here](https://typer.tiangolo.com/tutorial/options/version/#fix-with-is_eager).
            """
        ),
    ] = False,
    envvar: Annotated[
        Optional[Union[str, list[str]]],
        Doc(
            """
            Configure a CLI Option to read its value from an environment variable if it is not provided in the command line.
            For more information, see the [documentation on Environment Variables](https://typer.tiangolo.com/tutorial/arguments/envvar/).

            **Example**

            ```python
            @app.command()
            def main(user: Annotated[str, typer.Option(envvar="ME")]):
                print(f"Hello {user}")
            ```
            """
        ),
    ] = None,
    # TODO: Remove shell_complete in a future version (after 0.16.0)
    shell_complete: Annotated[
        Optional[
            Callable[
                [click.Context, click.Parameter, str],
                Union[list["click.shell_completion.CompletionItem"], list[str]],
            ]
        ],
        Doc(
            """
            **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.
            It is however not fully functional, and will likely be removed in future versions.
            """
        ),
    ] = None,
    autocompletion: Annotated[
        Optional[Callable[..., Any]],
        Doc(
            """
            Provide a custom function that helps to autocomplete the values of this CLI Option.
            See [the tutorial on parameter autocompletion](https://typer.tiangolo.com/tutorial/options-autocompletion) for more details.

            **Example**

            ```python
            def complete():
                return ["Me", "Myself", "I"]

            @app.command()
            def main(name: Annotated[str, typer.Option(autocompletion=complete)]):
                print(f"Hello {name}")
            ```
            """
        ),
    ] = None,
    default_factory: Annotated[
        Optional[Callable[[], Any]],
        Doc(
            """
            Provide a custom function that dynamically generates a [default](https://typer.tiangolo.com/tutorial/arguments/default) for this CLI Option.

            **Example**

            ```python
            def get_name():
                return random.choice(["Me", "Myself", "I"])

            @app.command()
            def main(name: Annotated[str, typer.Option(default_factory=get_name)]):
                print(f"Hello {name}")
            ```
            """
        ),
    ] = None,
    # Custom type
    parser: Annotated[
        Optional[Callable[[str], Any]],
        Doc(
            """
            Use your own custom types in Typer applications by defining a `parser` function that parses input into your own types:

            **Example**

            ```python
            class CustomClass:
                def __init__(self, value: str):
                    self.value = value

                def __str__(self):
                    return f"<CustomClass: value={self.value}>"

            def my_parser(value: str):
                return CustomClass(value * 2)

            @app.command()
            def main(opt: Annotated[CustomClass, typer.Option(parser=my_parser)] = "Foo"):
                print(f"--opt is {opt}")
            ```
            """
        ),
    ] = None,
    click_type: Annotated[
        Optional[click.ParamType],
        Doc(
            """
            Define this parameter to use a [custom Click type](https://click.palletsprojects.com/en/stable/parameters/#implementing-custom-types) in your Typer applications.

            **Example**

            ```python
            class MyClass:
                def __init__(self, value: str):
                    self.value = value

                def __str__(self):
                    return f"<MyClass: value={self.value}>"

            class MyParser(click.ParamType):
                name = "MyClass"

                def convert(self, value, param, ctx):
                    return MyClass(value * 3)

            @app.command()
            def main(opt: Annotated[MyClass, typer.Option(click_type=MyParser())] = "Foo"):
                print(f"--opt is {opt}")
            ```
            """
        ),
    ] = None,
    # Option
    show_default: Annotated[
        Union[bool, str],
        Doc(
            """
            When set to `False`, don't show the default value of this CLI Option in the [help text](https://typer.tiangolo.com/tutorial/options/help/).

            **Example**

            ```python
            @app.command()
            def main(name: Annotated[str, typer.Option(show_default=False)] = "Rick"):
                print(f"Hello {name}")
            ```
            """
        ),
    ] = True,
    prompt: Annotated[
        Union[bool, str],
        Doc(
            """
            When set to `True`, a prompt will appear to ask for the value of this CLI Option if it was not provided:

            **Example**

            ```python
            @app.command()
            def main(name: str, lastname: Annotated[str, typer.Option(prompt=True)]):
                print(f"Hello {name} {lastname}")
            ```
            """
        ),
    ] = False,
    confirmation_prompt: Annotated[
        bool,
        Doc(
            """
            When set to `True`, a user will need to type a prompted value twice (may be useful for passwords etc.).

            **Example**

            ```python
            @app.command()
            def main(project: Annotated[str, typer.Option(prompt=True, confirmation_prompt=True)]):
                print(f"Deleting project {project}")
            ```
            """
        ),
    ] = False,
    prompt_required: Annotated[
        bool,
        Doc(
            """
            **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.

            ---

            If this is `False` then a prompt is only shown if the option's flag is given without a value.
            """
        ),
    ] = True,
    hide_input: Annotated[
        bool,
        Doc(
            """
            When you've configured a prompt, for instance for [querying a password](https://typer.tiangolo.com/tutorial/options/password/),
            don't show anything on the screen while the user is typing the value.

            **Example**

            ```python
            @app.command()
            def login(
                name: str,
                password: Annotated[str, typer.Option(prompt=True, hide_input=True)],
            ):
                print(f"Hello {name}. Doing something very secure with password.")
            ```
            """
        ),
    ] = False,
    # TODO: remove is_flag and flag_value in a future release
    is_flag: Annotated[
        Optional[bool],
        Doc(
            """
            **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.
            It is however not fully functional, and will likely be removed in future versions.
            """
        ),
    ] = None,
    flag_value: Annotated[
        Optional[Any],
        Doc(
            """
            **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.
            It is however not fully functional, and will likely be removed in future versions.
            """
        ),
    ] = None,
    count: Annotated[
        bool,
        Doc(
            """
            Make a CLI Option work as a [counter](https://typer.tiangolo.com/tutorial/parameter-types/number/#counter-cli-options).
            The CLI option will have the `int` value representing the number of times the option was used on the command line.

            **Example**

            ```python
            @app.command()
            def main(verbose: Annotated[int, typer.Option("--verbose", "-v", count=True)] = 0):
                print(f"Verbose level is {verbose}")
            ```
            """
        ),
    ] = False,
    allow_from_autoenv: Annotated[
        bool,
        Doc(
            """
            **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.

            ---

            If this is enabled then the value of this parameter will be pulled from an environment variable in case a prefix is defined on the context.
            """
        ),
    ] = True,
    help: Annotated[
        Optional[str],
        Doc(
            """
            Help text for this CLI Option.
            See [the tutorial about CLI Options with help](https://typer.tiangolo.com/tutorial/options/help/) for more dedails.

            **Example**

            ```python
            @app.command()
            def greet(name: Annotated[str, typer.Option(help="Person to greet")] = "Deadpool"):
                print(f"Hello {name}")
            ```
            """
        ),
    ] = None,
    hidden: Annotated[
        bool,
        Doc(
            """
            Hide this CLI Option from [help outputs](https://typer.tiangolo.com/tutorial/options/help). `False` by default.

            **Example**

            ```python
            @app.command()
            def greet(name: Annotated[str, typer.Option(hidden=True)] = "Deadpool"):
                print(f"Hello {name}")
            ```
            """
        ),
    ] = False,
    show_choices: Annotated[
        bool,
        Doc(
            """
            **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.

            ---

            When set to `False`, this suppresses choices from being displayed inline when `prompt` is used.
            """
        ),
    ] = True,
    show_envvar: Annotated[
        bool,
        Doc(
            """
            When an ["envvar"](https://typer.tiangolo.com/tutorial/arguments/envvar) is defined, prevent it from showing up in the help text:

            **Example**

            ```python
            @app.command()
            def main(user: Annotated[str, typer.Option(envvar="ME", show_envvar=False)]):
                print(f"Hello {user}")
            ```
            """
        ),
    ] = True,
    # Choice
    case_sensitive: Annotated[
        bool,
        Doc(
            """
            For a CLI Option representing an [Enum (choice)](https://typer.tiangolo.com/tutorial/parameter-types/enum),
            you can allow case-insensitive matching with this parameter:

            **Example**

            ```python
            from enum import Enum

            class NeuralNetwork(str, Enum):
                simple = "simple"
                conv = "conv"
                lstm = "lstm"

            @app.command()
            def main(
                network: Annotated[NeuralNetwork, typer.Option(case_sensitive=False)]):
                print(f"Training neural network of type: {network.value}")
            ```

            With this setting, "LSTM" or "lstm" will both be valid values that will be resolved to `NeuralNetwork.lstm`.
            """
        ),
    ] = True,
    # Numbers
    min: Annotated[
        Optional[Union[int, float]],
        Doc(
            """
            For a CLI Option representing a [number](https://typer.tiangolo.com/tutorial/parameter-types/number/) (`int` or `float`),
            you can define numeric validations with `min` and `max` values:

            **Example**

            ```python
            @app.command()
            def main(
                user: Annotated[str, typer.Argument()],
                user_id: Annotated[int, typer.Option(min=1, max=1000)],
            ):
                print(f"ID for {user} is {user_id}")
            ```

            If the user attempts to input an invalid number, an error will be shown, explaining why the value is invalid.
            """
        ),
    ] = None,
    max: Annotated[
        Optional[Union[int, float]],
        Doc(
            """
            For a CLI Option representing a [number](https://typer.tiangolo.com/tutorial/parameter-types/number/) (`int` or `float`),
            you can define numeric validations with `min` and `max` values:

            **Example**

            ```python
            @app.command()
            def main(
                user: Annotated[str, typer.Argument()],
                user_id: Annotated[int, typer.Option(min=1, max=1000)],
            ):
                print(f"ID for {user} is {user_id}")
            ```

            If the user attempts to input an invalid number, an error will be shown, explaining why the value is invalid.
            """
        ),
    ] = None,
    clamp: Annotated[
        bool,
        Doc(
            """
            For a CLI Option representing a [number](https://typer.tiangolo.com/tutorial/parameter-types/number/) and that is bounded by using `min` and/or `max`,
            you can opt to use the closest minimum or maximum value instead of raising an error when the value is out of bounds. This is done by setting `clamp` to `True`.

            **Example**

            ```python
            @app.command()
            def main(
                user: Annotated[str, typer.Argument()],
                user_id: Annotated[int, typer.Option(min=1, max=1000, clamp=True)],
            ):
                print(f"ID for {user} is {user_id}")
            ```

            If the user attempts to input 3420 for `user_id`, this will internally be converted to `1000`.
            """
        ),
    ] = False,
    # DateTime
    formats: Annotated[
        Optional[list[str]],
        Doc(
            """
            For a CLI Option representing a [DateTime object](https://typer.tiangolo.com/tutorial/parameter-types/datetime),
            you can customize the formats that can be parsed automatically:

            **Example**

            ```python
            from datetime import datetime

            @app.command()
            def main(
                birthday: Annotated[
                    datetime,
                    typer.Option(
                        formats=["%Y-%m-%d", "%Y-%m-%d %H:%M:%S", "%m/%d/%Y"]
                    ),
                ],
            ):
                print(f"Birthday defined at: {birthday}")
            ```
            """
        ),
    ] = None,
    # File
    mode: Annotated[
        Optional[str],
        Doc(
            """
            For a CLI Option representing a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/),
            you can customize the mode to open the file with. If unset, Typer will set a [sensible value by default](https://typer.tiangolo.com/tutorial/parameter-types/file/#advanced-mode).

            **Example**

            ```python
            @app.command()
            def main(config: Annotated[typer.FileText, typer.Option(mode="a")]):
                config.write("This is a single line\\n")
                print("Config line written")
            ```
            """
        ),
    ] = None,
    encoding: Annotated[
        Optional[str],
        Doc(
            """
            Customize the encoding of this CLI Option represented by a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/).

            **Example**

            ```python
            @app.command()
            def main(config: Annotated[typer.FileText, typer.Option(encoding="utf-8")]):
                config.write("All the text gets written\\n")
            ```
            """
        ),
    ] = None,
    errors: Annotated[
        Optional[str],
        Doc(
            """
            **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.

            ---

            The error handling mode.
            """
        ),
    ] = "strict",
    lazy: Annotated[
        Optional[bool],
        Doc(
            """
            For a CLI Option representing a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/),
            by default the file will not be created until you actually start writing to it.
            You can change this behaviour by setting this parameter.
            By default, it's set to `True` for writing and to `False` for reading.

            **Example**

            ```python
            @app.command()
            def main(config: Annotated[typer.FileText, typer.Option(mode="a", lazy=False)]):
                config.write("This is a single line\\n")
                print("Config line written")
            ```
            """
        ),
    ] = None,
    atomic: Annotated[
        bool,
        Doc(
            """
            For a CLI Option representing a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/),
            you can ensure that all write instructions first go into a temporal file, and are only moved to the final destination after completing
            by setting `atomic` to `True`. This can be useful for files with potential concurrent access.

            **Example**

            ```python
            @app.command()
            def main(config: Annotated[typer.FileText, typer.Option(mode="a", atomic=True)]):
                config.write("All the text")
            ```
            """
        ),
    ] = False,
    # Path
    exists: Annotated[
        bool,
        Doc(
            """
            When set to `True` for a [`Path` CLI Option](https://typer.tiangolo.com/tutorial/parameter-types/path/),
            additional validation is performed to check that the file or directory exists. If not, the value will be invalid.

            **Example**

            ```python
            from pathlib import Path

            @app.command()
            def main(config: Annotated[Path, typer.Option(exists=True)]):
                text = config.read_text()
                print(f"Config file contents: {text}")
            ```
            """
        ),
    ] = False,
    file_okay: Annotated[
        bool,
        Doc(
            """
            Determine whether or not a [`Path` CLI Option](https://typer.tiangolo.com/tutorial/parameter-types/path/)
            is allowed to refer to a file. When this is set to `False`, the application will raise a validation error when a path to a file is given.

            **Example**

            ```python
            from pathlib import Path

            @app.command()
            def main(config: Annotated[Path, typer.Option(exists=True, file_okay=False)]):
                print(f"Directory listing: {[x.name for x in config.iterdir()]}")
            ```
            """
        ),
    ] = True,
    dir_okay: Annotated[
        bool,
        Doc(
            """
            Determine whether or not a [`Path` CLI Option](https://typer.tiangolo.com/tutorial/parameter-types/path/)
            is allowed to refer to a directory. When this is set to `False`, the application will raise a validation error when a path to a directory is given.

            **Example**

            ```python
            from pathlib import Path

            @app.command()
            def main(config: Annotated[Path, typer.Argument(exists=True, dir_okay=False)]):
                text = config.read_text()
                print(f"Config file contents: {text}")
            ```
            """
        ),
    ] = True,
    writable: Annotated[
        bool,
        Doc(
            """
            Whether or not to perform a writable check for this [`Path` CLI Option](https://typer.tiangolo.com/tutorial/parameter-types/path/).

            **Example**

            ```python
            from pathlib import Path

            @app.command()
            def main(config: Annotated[Path, typer.Option(writable=True)]):
                config.write_text("All the text")
            ```
            """
        ),
    ] = False,
    readable: Annotated[
        bool,
        Doc(
            """
            Whether or not to perform a readable check for this [`Path` CLI Option](https://typer.tiangolo.com/tutorial/parameter-types/path/).

            **Example**

            ```python
            from pathlib import Path

            @app.command()
            def main(config: Annotated[Path, typer.Option(readable=True)]):
                config.read_text("All the text")
            ```
            """
        ),
    ] = True,
    resolve_path: Annotated[
        bool,
        Doc(
            """
            Whether or not to fully resolve the path of this [`Path` CLI Option](https://typer.tiangolo.com/tutorial/parameter-types/path/),
            meaning that the path becomes absolute and symlinks are resolved.

            **Example**

            ```python
            from pathlib import Path

            @app.command()
            def main(config: Annotated[Path, typer.Option(resolve_path=True)]):
                config.read_text("All the text")
            ```
            """
        ),
    ] = False,
    allow_dash: Annotated[
        bool,
        Doc(
            """
            When set to `True`, a single dash for this [`Path` CLI Option](https://typer.tiangolo.com/tutorial/parameter-types/path/)
            would be a valid value, indicating standard streams. This is a more advanced use-case.
            """
        ),
    ] = False,
    path_type: Annotated[
        Union[None, type[str], type[bytes]],
        Doc(
            """
             A string type that will be used to represent this [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/).
             The default is `None` which means the return value will be either bytes or unicode, depending on what makes most sense given the input data.
             This is a more advanced use-case.
            """
        ),
    ] = None,
    # Rich settings
    rich_help_panel: Annotated[
        Union[str, None],
        Doc(
            """
            Set the panel name where you want this CLI Option to be shown in the [help text](https://typer.tiangolo.com/tutorial/arguments/help).

            **Example**

            ```python
            @app.command()
            def main(
                name: Annotated[str, typer.Argument(help="Who to greet")],
                age: Annotated[str, typer.Option(help="Their age", rich_help_panel="Data")],
            ):
                print(f"Hello {name} of age {age}")
            ```
            """
        ),
    ] = None,
) -> Any:
    """
    A [CLI Option](https://typer.tiangolo.com/tutorial/options) is a parameter to your command line application that is called with a single or double dash, something like `--verbose` or `-v`.

    Often, CLI Options are optional, meaning that users can omit them from the command. However, you can set them to be required by using `Annotated`
    and omitting a default value.

    ## Example

    ```python
    @app.command()
    def register(
        user: Annotated[str, typer.Argument()],
        age: Annotated[int, typer.Option(min=18)],
    ):
        print(f"User is {user}")
        print(f"--age is {age}")
    ```

    Note how in this example, `--age` is a required CLI Option.
    """
    return OptionInfo(
        # Parameter
        default=default,
        param_decls=param_decls,
        callback=callback,
        metavar=metavar,
        expose_value=expose_value,
        is_eager=is_eager,
        envvar=envvar,
        shell_complete=shell_complete,
        autocompletion=autocompletion,
        default_factory=default_factory,
        # Custom type
        parser=parser,
        click_type=click_type,
        # Option
        show_default=show_default,
        prompt=prompt,
        confirmation_prompt=confirmation_prompt,
        prompt_required=prompt_required,
        hide_input=hide_input,
        is_flag=is_flag,
        flag_value=flag_value,
        count=count,
        allow_from_autoenv=allow_from_autoenv,
        help=help,
        hidden=hidden,
        show_choices=show_choices,
        show_envvar=show_envvar,
        # Choice
        case_sensitive=case_sensitive,
        # Numbers
        min=min,
        max=max,
        clamp=clamp,
        # DateTime
        formats=formats,
        # File
        mode=mode,
        encoding=encoding,
        errors=errors,
        lazy=lazy,
        atomic=atomic,
        # Path
        exists=exists,
        file_okay=file_okay,
        dir_okay=dir_okay,
        writable=writable,
        readable=readable,
        resolve_path=resolve_path,
        allow_dash=allow_dash,
        path_type=path_type,
        # Rich settings
        rich_help_panel=rich_help_panel,
    )