forked from tylerdave/PyCon2019-Click-Tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tutorial.toml
225 lines (206 loc) · 6.31 KB
/
tutorial.toml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
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
name = "Click Tutorial"
[[parts]]
id = 1
name = "Command Parsing"
dir = "lessons/part_01"
file = "cli.py"
command = "part01"
[[parts.lessons]]
id = 1
name = "Hello, PyCon!"
test = "01_hello.py"
solution = "cli_01_hello.py"
objectives = """
* Learn how to use the `tutorial` command to run and check lessons.
* Make the tests for the first lesson pass by editing the working file.
"""
doc-urls = "https://click.palletsprojects.com/en/7.x/quickstart/#basic-concepts-creating-a-command"
[[parts.lessons]]
id = 2
name = "Arguments"
test = "02_args.py"
solution = "cli_02_args.py"
objectives = """
* Make the command accept a positional NAME argument
* accept any number of values
* print "Hello, NAME!" on a new line for each name given
* output nothing if no arguments are passed (noop)
"""
doc-urls = "https://click.palletsprojects.com/en/7.x/arguments/#variadic-arguments"
[[parts.lessons]]
id = 3
name = "Options"
test = "03_opts.py"
solution = "cli_03_opts.py"
objectives = """
* Add multiple options:
* Add a `--greeting` option that accepts a custom greeting
* Update to print "GREETING, NAME!" w/ the custom greeting
* Add a short alias for the option: `-g`
* Default to "Hello" if no greeting is passed
* Add a `--question` option as a flag that doesn't take a value
* If passed, end the greeting with "?"
* If not passed, end the greeting with "!"
"""
doc-urls = """|
https://click.palletsprojects.com/en/7.x/options/
https://click.palletsprojects.com/en/7.x/options/#boolean-flags
"""
[[parts.lessons]]
id = 4
name = "Help Documentation"
test = "04_help.py"
solution = "cli_04_help.py"
objectives = """
* Document your script
* Add general command usage help
* Include "Displays a greeting."
* Add help text to the `--greeting`:
* "Make the greeting a question"
* Add help text to and `--question`:
* "The greeting to display"
"""
doc-urls = "https://click.palletsprojects.com/en/7.x/documentation/"
[[parts.lessons]]
id = 5
name = "Input Validation"
test = "05_types.py"
solution = "cli_05_types.py"
objectives = """
* Add new options to show how type validation works
* Add `--int-option`
* Validate as integer
* Add output "int: {VALUE}" if value passed
* Add `--float-option`
* Validate as float
* Add output "float: {VALUE}" if value passed
* Add `--bool-option`
* Validate as boolean
* Add output "bool: {VALUE}" if value passed
* Add `--choice-option`
* Validate values are one of "A", "B", "C"
* Add output "choice: {VALUE}" if value passed
"""
doc-urls = """|
https://click.palletsprojects.com/en/7.x/parameters/#parameter-types
https://click.palletsprojects.com/en/7.x/options/#basic-value-options"""
[[parts]]
id = 2
name = "Input / Output"
dir = "lessons/part_02"
file = "cli.py"
command = "part02"
[[parts.lessons]]
id = 1
name = "Echo"
test = "01_echo.py"
solution = "cli_01_echo.py"
objectives = """
* Customize output destination and formatting
* Make "Hello!" print to stdout
* Make "Printing..." print to stderr
* Add a `--red` option that makes output text red when passed
"""
doc-urls = """|
https://click.palletsprojects.com/en/7.x/api/#click.echo
https://click.palletsprojects.com/en/7.x/api/#click.secho
"""
[[parts.lessons]]
id = 2
name = "File I/O"
test = "02_file_io.py"
solution = "cli_02_file_io.py"
objectives = """
* Read from and write to files or stdin/stdout depending on arguments
* Read the input source and write the contents to the output
* Accept an input file argument, reading from stdin by default (using `-` arg)
* Accept an output file argument, writing to stdout by default (using `-` arg)
* Find the length of the input data and print a message to stderr
"""
doc-urls = """|
https://click.palletsprojects.com/en/7.x/arguments/#file-arguments
https://click.palletsprojects.com/en/7.x/utils/#intelligent-file-opening
"""
[[parts]]
id = 3
name = "Nested Commands"
dir = "lessons/part_03"
file = "cli.py"
command = "part03"
[[parts.lessons]]
id = 1
name = "Command Groups"
test = "01_groups.py"
solution = "cli_01_groups.py"
objectives = """
* Make a command that has subcommands
* Add `hello` subcommand that prints "Hello!"
* See that trying to run nonexistent subcommands results in an error
"""
doc-urls = "https://click.palletsprojects.com/en/7.x/commands/"
[[parts.lessons]]
id = 2
name = "Sharing Contexts"
test = "02_contexts.py"
solution = "cli_02_contexts.py"
objectives = """
* Learn how parameters are handled by the group and by subcommands
* Pass `--verbose` group option to `hello` subcommand via `pass_context`
* Store the value in the context's `obj`
* If verbose is True, print "VERBOSE is on" to `stderr`
* Add a new `goodbye` subcommand
* Pass `--verbose` group option to `goodbye` via `pass_obj`
* If verbose is True, print "VERBOSE is on" to `stderr`
"""
doc-urls = "https://click.palletsprojects.com/en/7.x/commands/#passing-parameters"
[[parts]]
id = 4
name = "Packaging"
dir = "lessons/part_04"
[[parts.lessons]]
id = 1
name = "Cookiecutter"
objectives = """
* Use `cookiecutter` to make a new project directory
* `cd` to `lessons/part_04`
* `cookiecutter https://github.com/audreyr/cookiecutter-pypackage`
* Fill in the prompts with your own values
* Be sure to enable click CLI
"""
doc-urls = "https://cookiecutter.readthedocs.io/en/latest/"
[[parts.lessons]]
id = 2
name = "Installing Editable"
objectives = """
* Install your new package in editable mode
* Optionally create a new virtualenv
* Install via `pip install -e .` within the package dir.
"""
doc-urls = "https://the-hitchhikers-guide-to-packaging.readthedocs.io/en/latest/pip.html#installing-from-a-vcs"
[[parts.lessons]]
id = 3
name = "Distribution Packages"
objectives = """
* Build distribution packages for your project
* `python setup.py sdist bdist_wheel`
* Via `Makefile`: `make build`
"""
doc-urls = "https://the-hitchhikers-guide-to-packaging.readthedocs.io/en/latest/creation.html#creating-your-distribution-file"
[[parts]]
id = 5
name = "Bonus"
dir = "lessons/part_05"
file = "cli.py"
command = "part05"
[[parts.lessons]]
id = 1
name = "Bonus Examples"
objectives = """
* See the command for examples of click features
* Paging
* Launching Editor
* Launching Applications
* Finding Application Folder
* Progress Bar
"""
doc-urls = "https://the-hitchhikers-guide-to-packaging.readthedocs.io/en/latest/creation.html#creating-your-distribution-file"