feat: Add 1 and update 3 files
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 33s
Build-Test-Publish / build (linux/arm64) (push) Successful in 2m44s

This commit is contained in:
j
2026-02-21 22:53:53 +13:00
parent dc66c950a1
commit 31fc29fdfb
4 changed files with 73 additions and 1 deletions

View File

@@ -71,7 +71,7 @@ fi
# GPU list (may have 0, 1, or multiple) # GPU list (may have 0, 1, or multiple)
GPU_JSON="[]" GPU_JSON="[]"
if command -v lspci &>/dev/null; then 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 if [ -n "$GPU_LINES" ]; then
GPU_JSON="[" GPU_JSON="["
first=true first=true

View File

@@ -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<std::string> 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

View File

@@ -440,6 +440,21 @@
return templates; return templates;
} }
std::vector<std::pair<std::string, std::string>> template_manager::get_template_list_with_source() const
{
ASSERT(mLoaded && mSources.size() > 0, "Template manager not loaded, or no template sources found.");
std::vector<std::pair<std::string, std::string>> result;
std::set<std::string> 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 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."); ASSERT(mLoaded && mSources.size() > 0, "Template manager not loaded, or no template sources found.");

View File

@@ -97,6 +97,7 @@ class template_manager {
static bool check_template_shell_scripts_syntax(const std::string& template_path); static bool check_template_shell_scripts_syntax(const std::string& template_path);
void list_templates() const; void list_templates() const;
std::vector<std::pair<std::string, std::string>> get_template_list_with_source() const;
void load_sources(); void load_sources();
void print_sources() const; void print_sources() const;