diff --git a/subprojects/extensions-tool/completion/bash/gnome-extensions b/subprojects/extensions-tool/completion/bash/gnome-extensions index 9630ce9d7..05cd03926 100644 --- a/subprojects/extensions-tool/completion/bash/gnome-extensions +++ b/subprojects/extensions-tool/completion/bash/gnome-extensions @@ -44,6 +44,14 @@ __gnome_extensions() { esac case "$COMMAND" in + create) + case "$prev" in + --template) + COMPREPLY=($(compgen -W "`gnome-extensions create --list-templates`" -- "$2")) + return 0 + ;; + esac + ;; pack) case "$prev" in --podir|--out-dir|-o) diff --git a/subprojects/extensions-tool/man/gnome-extensions.txt b/subprojects/extensions-tool/man/gnome-extensions.txt index d94c0bd2e..adc08e97a 100644 --- a/subprojects/extensions-tool/man/gnome-extensions.txt +++ b/subprojects/extensions-tool/man/gnome-extensions.txt @@ -128,6 +128,9 @@ Creates a new extension from a template. *--uuid*='UUID'::: Set the unique extension ID in the metadata to 'UUID' + *--template*='TEMPLATE'::: + Use 'TEMPLATE' as base for the new extension + *-i*::: *--interactive*::: Prompt for any extension metadata that hasn't been provided diff --git a/subprojects/extensions-tool/src/command-create.c b/subprojects/extensions-tool/src/command-create.c index d51d4dac6..37a3118bc 100644 --- a/subprojects/extensions-tool/src/command-create.c +++ b/subprojects/extensions-tool/src/command-create.c @@ -208,11 +208,14 @@ launch_extension_source (GFile *dir, GError **error) } static gboolean -create_extension (const char *uuid, const char *name, const char *description) +create_extension (const char *uuid, const char *name, const char *description, const char *template) { g_autoptr (GFile) dir = NULL; g_autoptr (GError) error = NULL; + if (template == NULL) + template = "plain"; + dir = g_file_new_build_filename (g_get_user_data_dir (), "gnome-shell", "extensions", @@ -231,7 +234,7 @@ create_extension (const char *uuid, const char *name, const char *description) return FALSE; } - if (!copy_extension_template ("plain", dir, &error)) + if (!copy_extension_template (template, dir, &error)) { g_printerr ("%s\n", error->message); return FALSE; @@ -328,6 +331,7 @@ handle_create (int argc, char *argv[], gboolean do_help) g_autofree char *name = NULL; g_autofree char *description = NULL; g_autofree char *uuid = NULL; + g_autofree char *template = NULL; gboolean interactive = FALSE; gboolean list_templates = FALSE; GOptionEntry entries[] = { @@ -343,6 +347,10 @@ handle_create (int argc, char *argv[], gboolean do_help) .arg_description = _("DESCRIPTION"), .arg = G_OPTION_ARG_STRING, .arg_data = &description, .description = _("A short description of what the extension does") }, + { .long_name = "template", + .arg = G_OPTION_ARG_STRING, .arg_data = &template, + .arg_description = _("TEMPLATE"), + .description = _("The template to use for the new extension") }, { .long_name = "list-templates", .arg = G_OPTION_ARG_NONE, .arg_data = &list_templates, .flags = G_OPTION_FLAG_HIDDEN }, @@ -403,5 +411,5 @@ handle_create (int argc, char *argv[], gboolean do_help) return 1; } - return create_extension (uuid, name, description) ? 0 : 2; + return create_extension (uuid, name, description, template) ? 0 : 2; }