[gnome-shell] extensions-tool: Add --template create option
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] extensions-tool: Add --template create option
- Date: Tue, 7 Apr 2020 20:33:42 +0000 (UTC)
commit 6f6251c0bca96feab20e9cb36aa8e4256f776a29
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Nov 7 12:46:47 2019 +0100
extensions-tool: Add --template create option
We now have everything in place to allow users to pick a template
other than the default one (although at the moment it's the only
one we have), so add a corresponding option.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/812
.../extensions-tool/completion/bash/gnome-extensions | 8 ++++++++
subprojects/extensions-tool/man/gnome-extensions.txt | 3 +++
subprojects/extensions-tool/src/command-create.c | 14 +++++++++++---
3 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/subprojects/extensions-tool/completion/bash/gnome-extensions
b/subprojects/extensions-tool/completion/bash/gnome-extensions
index 9630ce9d77..05cd039269 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 d94c0bd2e3..adc08e97a2 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 d51d4dac64..37a3118bce 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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]