diff --git a/source/agent-remote/hostinfo.sh b/source/agent-remote/hostinfo.sh index 45e9618..25e78a4 100755 --- a/source/agent-remote/hostinfo.sh +++ b/source/agent-remote/hostinfo.sh @@ -71,7 +71,7 @@ fi # GPU list (may have 0, 1, or multiple) GPU_JSON="[]" if command -v lspci &>/dev/null; then - GPU_LINES=$(lspci 2>/dev/null | grep -i 'vga\|3d\|display' | sed 's/^[^ ]* //; s/VGA compatible controller: //; s/3D controller: //; s/Display controller: //' || true) + GPU_LINES=$(lspci 2>/dev/null | grep -i 'VGA compatible controller\|3D controller\|Display controller' | sed 's/^[^ ]* //; s/VGA compatible controller: //; s/3D controller: //; s/Display controller: //' || true) if [ -n "$GPU_LINES" ]; then GPU_JSON="[" first=true diff --git a/source/src/commands/list-templates.cpp b/source/src/commands/list-templates.cpp new file mode 100644 index 0000000..2d05584 --- /dev/null +++ b/source/src/commands/list-templates.cpp @@ -0,0 +1,56 @@ +#include "command_registry.hpp" +#include "templates.hpp" +#include "utils/output.hpp" +#include "tableprint.hpp" + +namespace dropshell { + +int list_templates_handler(const CommandContext &ctx); + +static std::vector list_templates_name_list = {"list-templates", "ls-templates", "templates"}; + +void list_templates_autocomplete(const CommandContext &ctx) { + // no arguments +} + +struct ListTemplatesCommandRegister { + ListTemplatesCommandRegister() { + CommandRegistry::instance().register_command({ + list_templates_name_list, + list_templates_handler, + list_templates_autocomplete, + false, // hidden + true, // requires_config + true, // requires_install + 0, // min_args + 0, // max_args + "list-templates", + "List all available templates and their sources.", + R"( +List all available templates from configured local paths and registries. + list-templates Show template names and where they come from. + )" + }); + } +} list_templates_command_register; + +int list_templates_handler(const CommandContext &ctx) { + auto templates = gTemplateManager().get_template_list_with_source(); + + if (templates.empty()) { + info << "No templates found." << std::endl; + return 0; + } + + tableprint tp("Available Templates"); + tp.add_row({"Template", "Source"}); + + for (const auto &[name, source] : templates) + tp.add_row({name, source}); + + tp.sort({1, 0}); + tp.print(); + return 0; +} + +} // namespace dropshell diff --git a/source/src/templates.cpp b/source/src/templates.cpp index 7df0665..c947258 100644 --- a/source/src/templates.cpp +++ b/source/src/templates.cpp @@ -440,6 +440,21 @@ return templates; } + std::vector> template_manager::get_template_list_with_source() const + { + ASSERT(mLoaded && mSources.size() > 0, "Template manager not loaded, or no template sources found."); + std::vector> result; + std::set seen; + for (const auto& source : mSources) { + auto source_templates = source->get_template_list(); + for (const auto& t : source_templates) { + if (seen.insert(t).second) + result.push_back({t, source->get_description()}); + } + } + return result; + } + bool template_manager::has_template(const std::string &template_name) const { ASSERT(mLoaded && mSources.size() > 0, "Template manager not loaded, or no template sources found."); diff --git a/source/src/templates.hpp b/source/src/templates.hpp index f2f6249..ffa3f83 100644 --- a/source/src/templates.hpp +++ b/source/src/templates.hpp @@ -97,6 +97,7 @@ class template_manager { static bool check_template_shell_scripts_syntax(const std::string& template_path); void list_templates() const; + std::vector> get_template_list_with_source() const; void load_sources(); void print_sources() const;