From 3dd57464c12fb6f304fcc09ab44886fee267a2af Mon Sep 17 00:00:00 2001 From: jakub-nt <175944085+jakub-nt@users.noreply.github.com> Date: Fri, 19 Sep 2025 15:12:57 +0200 Subject: [PATCH 1/3] Updated outdated doc Signed-off-by: jakub-nt <175944085+jakub-nt@users.noreply.github.com> --- JSON.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JSON.md b/JSON.md index be2e599a..73540b29 100644 --- a/JSON.md +++ b/JSON.md @@ -204,7 +204,7 @@ The modules inside `build`, `provides`, and `index` use these fields: For modules in `provides`, must refer to other modules in `provides` or `index` (default one if not specified). For modules in `build`, must refer to other modules in `build`. - `added_by` (string): Information about how the module was added to `build`. - Name of the module which added it as a dependency, or `"cfbs add"` if the user added the module itself. + Name of the module which added it as a dependency, or name of the used command (`"cfbs add"`, `"cfbs init"`, `"cfbs convert"`) if the user added the module itself. Optional in `build` modules, not accepted in `provides` or `index`. - `steps` (array of strings): The operations performed (in order) to build the module. See the section below on build steps. From f4153cf757c6b1bb7725bee0229dba5810a5f521 Mon Sep 17 00:00:00 2001 From: jakub-nt <175944085+jakub-nt@users.noreply.github.com> Date: Fri, 19 Sep 2025 15:13:22 +0200 Subject: [PATCH 2/3] Fixed typo Signed-off-by: jakub-nt <175944085+jakub-nt@users.noreply.github.com> --- cfbs/updates.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cfbs/updates.py b/cfbs/updates.py index 608eaa24..faa162b1 100644 --- a/cfbs/updates.py +++ b/cfbs/updates.py @@ -42,7 +42,7 @@ def update_input_data(module, input_data) -> bool: def _update_keys(input_def, input_data, keys): """ - Update keys that can be safily updated in input data. + Update keys that can be safely updated in input data. """ changes_made = False for key in keys: From eeb9e467edc50460552589edd979f0b55a085aae Mon Sep 17 00:00:00 2001 From: jakub-nt <175944085+jakub-nt@users.noreply.github.com> Date: Fri, 19 Sep 2025 15:14:26 +0200 Subject: [PATCH 3/3] Improved `cfbs show` output Signed-off-by: jakub-nt <175944085+jakub-nt@users.noreply.github.com> --- cfbs/commands.py | 64 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 13 deletions(-) diff --git a/cfbs/commands.py b/cfbs/commands.py index d2b26eeb..7f78ce9f 100644 --- a/cfbs/commands.py +++ b/cfbs/commands.py @@ -948,19 +948,26 @@ def help_command(): def _print_module_info(data): + def human_readable(key: str): + if key == "repo": + return "Repository" + if key == "url": + return "URL" + return key.title().replace("_", " ") + ordered_keys = [ "module", - "version", - "status", - "by", + "description", "tags", - "repo", + "dependencies", "index", - "commit", "subdirectory", - "dependencies", - "added_by", - "description", + "url", + "repo", + "version", + "commit", + "by", + "status", ] for key in ordered_keys: if key in data: @@ -968,12 +975,12 @@ def _print_module_info(data): value = ", ".join(data[key]) else: value = data[key] - print("{}: {}".format(key.title().replace("_", " "), value)) + print("{}: {}".format(human_readable(key), value)) @cfbs_command("show") @cfbs_command("info") -def info_command(modules): +def info_command(modules: List[str]): if not modules: raise CFBSExitError( "info/show command requires one or more module names as arguments" @@ -996,14 +1003,14 @@ def info_command(modules): if in_build: # prefer information from the local source data = next(m for m in build if m["name"] == module) - data["status"] = "Added" + status_text = "Added" elif module in index: data = index[module] if "alias" in data: alias = module module = data["alias"] data = index[module] - data["status"] = "Added" if in_build else "Not added" + status_text = "Added" if in_build else "Not added" else: if not module.startswith("./"): module = "./" + module @@ -1011,7 +1018,38 @@ def info_command(modules): if data is None: print("Path {} exists but is not yet added as a module.".format(module)) continue - data["status"] = "Added" + status_text = "Added" + + if status_text == "Added": + if "added_by" in data: + if data["added_by"] == "cfbs convert": + status_text = "Added during 'cfbs convert'" + elif data["added_by"] == "cfbs init": + if "url" in data: + status_text = "Added from URL (not from default index)" + else: + status_text = "Added from name" + status_text += " during 'cfbs init'" + elif data["added_by"].startswith("cfbs "): + # normally "cfbs add" - written more generally as a safer fallback + if "url" in data: + status_text = ( + "Added by 'cfbs add ', not from default index" + ) + else: + status_text = "Added by 'cfbs add '" + else: + status_text = "Added by %s as a dependency" % data["added_by"] + + if "input" in data: + input_path = os.path.join(data["name"], "input.json") + if not input_path.startswith("./"): + input_path = "./" + input_path + if os.path.isfile(input_path): + status_text += ", has input in %s" % input_path + else: + status_text += ", supports input (but has no input yet)" + data["status"] = status_text data["module"] = (module + "({})".format(alias)) if alias else module _print_module_info(data) print() # extra line for ease of reading