cli.py
Command line entrypoint. This module declares the Copier CLI applications.
Basically, there are 3 different commands you can run:
-
copier
, the main app, which is a shortcut for thecopy
andupdate
subapps.If the destination project is found and has an answers file with enough information, it will become a shortcut for
copier update
.Otherwise it will be a shortcut for
copier copy
.Example
# Copy a new project copier gh:copier-org/autopretty my-project # Update it cd my-project copier
-
copier copy
, used to bootstrap a new project from a template.Example
copier copy gh:copier-org/autopretty my-project
-
copier update
to update a preexisting project to a newer version of its template.Example
copier update
Below are the docs of each one of those.
CopierApp
¶
Bases: cli.Application
The Copier CLI application.
Attributes:
Name | Type | Description |
---|---|---|
answers_file |
cli.SwitchAttr
|
Set answers_file option. |
exclude |
cli.SwitchAttr
|
Set exclude option. |
vcs_ref |
cli.SwitchAttr
|
Set vcs_ref option. |
pretend |
cli.Flag
|
Set pretend option. |
force |
cli.Flag
|
Set force option. |
defaults |
cli.Flag
|
Set defaults option. |
overwrite |
cli.Flag
|
Set overwrite option. |
skip |
cli.Flag
|
Set skip_if_exists option. |
prereleases |
cli.Flag
|
Set use_prereleases option. |
quiet |
cli.Flag
|
Set quiet option. |
Source code in copier/cli.py
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 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 |
|
data_switch(values)
¶
Update data with provided values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values |
List[str]
|
The list of values to apply.
Each value in the list is of the following form: |
required |
Source code in copier/cli.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|
main(*args)
¶
Copier CLI app shortcuts.
This method redirects abstract CLI calls
(those that don't specify copy
or update
)
to CopierCopySubApp.main
or CopierUpdateSubApp.main
automatically.
Examples:
copier from to
→copier copy from to
copier from
→copier update from
copier
→copier update .
Source code in copier/cli.py
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 |
|
CopierCopySubApp
¶
Bases: cli.Application
The copier copy
subcommand.
Use this subcommand to bootstrap a new subproject from a template, or to override a preexisting subproject ignoring its history diff.
Attributes:
Name | Type | Description |
---|---|---|
cleanup_on_error |
cli.Flag
|
Set cleanup_on_error option. |
Source code in copier/cli.py
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 |
|
main(template_src, destination_path)
¶
Call run_copy.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
template_src |
str
|
Indicate where to get the template from. This can be a git URL or a local path. |
required |
destination_path |
str
|
Where to generate the new subproject. It must not exist or be empty. |
required |
Source code in copier/cli.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
|
CopierUpdateSubApp
¶
Bases: cli.Application
The copier update
subcommand.
Use this subcommand to update an existing subproject from a template that supports updates.
Source code in copier/cli.py
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 |
|
main(destination_path='.')
¶
Call run_update.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
destination_path |
cli.ExistingDirectory
|
Only the destination path is needed to update, because the
The subproject must exist. If not specified, the currently working directory is used. |
'.'
|
Source code in copier/cli.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
|
handle_exceptions(method)
¶
Handle keyboard interruption while running a method.
Source code in copier/cli.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|