diff --git a/cd/__init__.py b/cd/__init__.py index 5fc2a66..83dac8f 100644 --- a/cd/__init__.py +++ b/cd/__init__.py @@ -10,6 +10,21 @@ projects = Projects(os.environ) project = Project(projects) +def cd_browse_workspace(): + print(f'''\ +{project.root} +↓ +''', end=str()) + files = [] + for directory, directories, files in os.walk(project.root): + for file in files: + absolute_path = os.path.join(directory, file) + relative_path = os.path.relpath(absolute_path, start=project.root) + files.append(relative_path) + for file in files: + print(file) + + def cd_clone_branch(): print(f'''\ {project.url} @@ -32,6 +47,7 @@ def cd_list_environment(): def install_commands(path): user = '/usr/local/bin' for command in [ + 'browse-workspace', 'clone-branch', 'list-environment', ]: diff --git a/cd/project.py b/cd/project.py index b5740e2..d5a96d7 100644 --- a/cd/project.py +++ b/cd/project.py @@ -8,6 +8,10 @@ NAME = [ 'GITHUB_REPOSITORY', 'CI_PROJECT_PATH', ] +ROOT = [ + 'GITHUB_WORKSPACE', + 'CI_PROJECT_DIR', +] class Project: @@ -21,5 +25,9 @@ class Project: for variable in NAME: if value := projects.environment.get(variable, None): self.name = path.basename(value) + # root + for variable in ROOT: + if value := projects.environment.get(variable, None): + self.root = value # url self.url = path.join(projects.url, self.name)