init_developer.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/usr/bin/env python3
  2. """
  3. Initialize developer for workflow.
  4. Usage:
  5. python3 init_developer.py <developer-name>
  6. This creates:
  7. - .trellis/.developer file with developer info
  8. - .trellis/workspace/<name>/ directory structure
  9. """
  10. from __future__ import annotations
  11. import sys
  12. from common.paths import (
  13. DIR_WORKFLOW,
  14. FILE_DEVELOPER,
  15. get_developer,
  16. )
  17. from common.developer import init_developer
  18. def main() -> None:
  19. """CLI entry point."""
  20. if len(sys.argv) < 2:
  21. print(f"Usage: {sys.argv[0]} <developer-name>")
  22. print()
  23. print("Example:")
  24. print(f" {sys.argv[0]} john")
  25. sys.exit(1)
  26. name = sys.argv[1]
  27. # Check if already initialized
  28. existing = get_developer()
  29. if existing:
  30. print(f"Developer already initialized: {existing}")
  31. print()
  32. print(f"To reinitialize, remove {DIR_WORKFLOW}/{FILE_DEVELOPER} first")
  33. sys.exit(0)
  34. if init_developer(name):
  35. sys.exit(0)
  36. else:
  37. sys.exit(1)
  38. if __name__ == "__main__":
  39. main()