Skip to content

Commit

Permalink
Make the longest module name length function more generic
Browse files Browse the repository at this point in the history
Signed-off-by: jakub-nt <[email protected]>
  • Loading branch information
jakub-nt committed Jul 22, 2024
1 parent 9dab8ac commit 9d0ad4d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cfbs/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def perform_build_steps(config) -> int:
user_error("No 'build' key found in the configuration")
return 1
print("\nSteps:")
module_name_length = config.longest_module_name()
module_name_length = config.longest_module_key_length("name")
for module in config.get("build", []):
for step in module["steps"]:
_perform_build_step(module, step, module_name_length)
Expand Down
4 changes: 2 additions & 2 deletions cfbs/cfbs_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def save(self):
with open(self.path, "w") as f:
f.write(data)

def longest_module_name(self) -> int:
return max((len(m["name"]) for m in self["build"])) if self.get("build") else 0
def longest_module_key_length(self, key) -> int:
return max((len(m[key]) for m in self["build"])) if self.get("build") else 0

def add_with_dependencies(self, module, remote_config=None, dependent=None):
if type(module) is list:
Expand Down
4 changes: 2 additions & 2 deletions cfbs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def status_command() -> int:
if not modules:
return 0
print("\nModules:")
max_length = config.longest_module_name()
max_length = config.longest_module_key_length("name")
counter = 1
for m in modules:
if m["name"].startswith("./"):
Expand Down Expand Up @@ -843,7 +843,7 @@ def _download_dependencies(
# 2. Code for copying things into ./out
print("\nModules:")
counter = 1
max_length = config.longest_module_name()
max_length = config.longest_module_key_length("name")
downloads = os.path.join(cfbs_dir(), "downloads")
for module in config.get("build", []):
name = module["name"]
Expand Down

0 comments on commit 9d0ad4d

Please sign in to comment.