MCPcopy Create free account
hub / github.com/copier-org/copier / main

Method main

copier/_cli.py:518–567  ·  view source on GitHub ↗

Call get_update_data, parse its output, and write to console. Parameters: destination_path: Only the destination path is needed to check, because the `src_path` comes from [the answers file][the-copier-answersyml-file]. The subpro

(self, destination_path: str = ".")

Source from the content-addressed store, hash-verified

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 """
529
530 def inner() -> int:
531 update_available, current_version, latest_version = get_update_data(
532 dst_path=destination_path,
533 answers_file=self.answers_file,
534 use_prereleases=self.prereleases,
535 )
536
537 update_json = json.dumps(
538 {
539 "update_available": update_available,
540 "current_version": current_version,
541 "latest_version": latest_version,
542 }
543 )
544
545 if update_available:
546 if self.quiet:
547 return 2
548 if self.output_format == "json":
549 # TODO Unify printing tools
550 print(update_json)
551 else:
552 # TODO Unify printing tools
553 print(
554 "New template version available.\n"
555 f"Current version is {current_version}, "
556 f"latest version is {latest_version}."
557 )
558 elif not self.quiet:
559 if self.output_format == "json":
560 # TODO Unify printing tools
561 print(update_json)
562 else:
563 # TODO Unify printing tools
564 print("Project is up-to-date!")
565 return 0
566
567 return _handle_exceptions(inner)

Callers

nothing calls this directly

Calls 1

_handle_exceptionsFunction · 0.85

Tested by

no test coverage detected