Skip to content

Commit ff88107

Browse files
committed
Update README
1 parent 7c224cc commit ff88107

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

README.rst

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@ filename/filepath validator for argparse
135135
parser.add_argument("--filepath", type=filepath)
136136
parser.add_argument("--filename", type=filename)
137137
138+
:Output:
139+
.. code-block::
140+
141+
$ ./examples/argparse_validate.py --filepath e?g
142+
usage: argparse_validate.py [-h] [--filepath FILEPATH] [--filename FILENAME]
143+
argparse_validate.py: error: argument --filepath: invalid char found: invalids=('?'), value='e?g', reason=INVALID_CHARACTER, target-platform=Windows
144+
138145
filename/filepath validator for click
139146
---------------------------------------
140147
:Sample Code:
@@ -144,11 +151,24 @@ filename/filepath validator for click
144151
145152
from pathvalidate.click import filename, filepath
146153
154+
147155
@click.command()
148156
@click.option("--filename", callback=filename)
149157
@click.option("--filepath", callback=filepath)
150158
def cli(filename, filepath):
151-
# do something
159+
click.echo(filename, filepath)
160+
161+
162+
if __name__ == "__main__":
163+
cli()
164+
165+
:Output:
166+
.. code-block::
167+
168+
$ ./examples/click_validate.py --filepath e?g
169+
Usage: click_validate.py [OPTIONS]
170+
171+
Error: Invalid value for "--filepath": invalid char found: invalids=('?'), value='e?g', reason=INVALID_CHARACTER, target-platform=Windows
152172
153173
For more information
154174
----------------------

0 commit comments

Comments
 (0)