spcd/cd/__init__.py
Marc Beninca 3211cbea65
Some checks failed
/ job (push) Failing after 1m3s
fix
2024-04-28 18:48:01 +02:00

39 lines
773 B
Python

import os
from cd.project import Project
from cd.projects import Projects
from rwx import ps
COMMANDS_PREFIX = 'cd-'
projects = Projects(os.environ)
project = Project(projects)
def cd_clone_branch():
print(f'''\
{project.url}
''', end=str(), flush=True)
ps.run('git',
'clone',
'--branch', project.branch,
'--',
project.url,
os.path.realpath(os.curdir),
)
def cd_list_environment():
for variable, value in sorted(os.environ.items()):
print(variable, '=', value)
def install_commands(path):
user = '/usr/local/bin'
for command in [
'clone-branch',
'list-environment',
]:
print(command)
os.symlink(path, os.path.join(user, f'{COMMANDS_PREFIX}{command}'))