From e191f3cc4ddaf3e24ec8a6ceb2993f6f532d2f3d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Thu, 30 May 2024 00:21:42 +0200 Subject: [PATCH] browse-workspace --- cd/__init__.py | 16 ++++++++++++++++ cd/project.py | 8 ++++++++ 2 files changed, 24 insertions(+) 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)