spcd/pidd/cmd.py
2024-06-24 15:33:12 +02:00

64 lines
1.2 KiB
Python

import os
from pathlib import Path
from cd import browse, project, projects
from rwx import ps, split
from rwx.log import log
def pidd_browse_workspace() -> None:
browse(project.root)
def pidd_build_project() -> None:
for extension in ["py", "sh"]:
path = Path(project.root) / f"build.{extension}"
if path.exists():
ps.run(path)
break
else:
pass
def pidd_clone_branch() -> None:
log.info(projects)
split()
log.info(project)
split()
log.info(f"""\
{project.url}
""")
ps.run(
"git",
"clone",
"--branch",
project.branch,
"--",
project.url,
project.root,
)
def pidd_list_environment() -> None:
for variable, value in sorted(projects.environment.items()):
log.info(f"{variable} = {value}")
def pidd_synchronize() -> None:
host = "rwx.work"
source = "out"
user = "cd"
#
root = Path(os.sep) / user / project.branch / projects.group / project.name
#
target = f"{user}@{host}:{root}"
ps.run(
"rsync",
"--archive",
"--delete-before",
"--verbose",
f"{source}/",
f"{target}/",
"--dry-run",
)