The `copier check-update` subcommand. Use this subcommand to check if an existing subproject is using the latest version of a template.
| 469 | |
| 470 | @CopierApp.subcommand("check-update") |
| 471 | class CopierCheckUpdateSubApp(cli.Application): |
| 472 | """The `copier check-update` subcommand. |
| 473 | |
| 474 | Use this subcommand to check if an existing subproject is using the |
| 475 | latest version of a template. |
| 476 | |
| 477 | """ |
| 478 | |
| 479 | DESCRIPTION = "Check if a copy is using the latest version of its original template" |
| 480 | DESCRIPTION_MORE = dedent( |
| 481 | """\ |
| 482 | The copy must have a valid answers file which contains info |
| 483 | from the last Copier execution, including the source template |
| 484 | (it must be a key called `_src_path`). |
| 485 | |
| 486 | If that file contains also `_commit` and `destination_path` is a git |
| 487 | repository, this command will do its best to determine whether a newer |
| 488 | version is available, applying PEP 440 to the template's history. |
| 489 | """ |
| 490 | ) |
| 491 | |
| 492 | answers_file = cli.SwitchAttr( |
| 493 | ["-a", "--answers-file"], |
| 494 | default=None, |
| 495 | help=( |
| 496 | "Check for updates using this path (relative to `destination_path`) " |
| 497 | "to find the answers file" |
| 498 | ), |
| 499 | ) |
| 500 | quiet = cli.Flag( |
| 501 | ["-q", "--quiet"], |
| 502 | help=( |
| 503 | "Suppress status output, exit with status 2 when a new template version is " |
| 504 | "available" |
| 505 | ), |
| 506 | ) |
| 507 | prereleases = cli.Flag( |
| 508 | ["-g", "--prereleases"], |
| 509 | help="Use prereleases to compare template VCS tags.", |
| 510 | ) |
| 511 | output_format = cli.SwitchAttr( |
| 512 | ["--output-format"], |
| 513 | cli.Set("plain", "json"), |
| 514 | default="plain", |
| 515 | help="Output format, either 'plain' (the default) or 'json'.", |
| 516 | ) |
| 517 | |
| 518 | def main(self, destination_path: str = ".") -> int: |
| 519 | """Call get_update_data, parse its output, and write to console. |
| 520 | |
| 521 | Parameters: |
| 522 | destination_path: |
| 523 | Only the destination path is needed to check, because the |
| 524 | `src_path` comes from [the answers file][the-copier-answersyml-file]. |
| 525 | |
| 526 | The subproject must exist. If not specified, the currently |
| 527 | working directory is used. |
| 528 | """ |
nothing calls this directly
no outgoing calls
no test coverage detected