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
This commit is contained in:
parent
fd034e3551
commit
6f6251c0bc
@ -44,6 +44,14 @@ __gnome_extensions() {
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
case "$COMMAND" in
|
case "$COMMAND" in
|
||||||
|
create)
|
||||||
|
case "$prev" in
|
||||||
|
--template)
|
||||||
|
COMPREPLY=($(compgen -W "`gnome-extensions create --list-templates`" -- "$2"))
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
pack)
|
pack)
|
||||||
case "$prev" in
|
case "$prev" in
|
||||||
--podir|--out-dir|-o)
|
--podir|--out-dir|-o)
|
||||||
|
@ -128,6 +128,9 @@ Creates a new extension from a template.
|
|||||||
*--uuid*='UUID':::
|
*--uuid*='UUID':::
|
||||||
Set the unique extension ID in the metadata to 'UUID'
|
Set the unique extension ID in the metadata to 'UUID'
|
||||||
|
|
||||||
|
*--template*='TEMPLATE':::
|
||||||
|
Use 'TEMPLATE' as base for the new extension
|
||||||
|
|
||||||
*-i*:::
|
*-i*:::
|
||||||
*--interactive*:::
|
*--interactive*:::
|
||||||
Prompt for any extension metadata that hasn't been provided
|
Prompt for any extension metadata that hasn't been provided
|
||||||
|
@ -208,11 +208,14 @@ launch_extension_source (GFile *dir, GError **error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
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 (GFile) dir = NULL;
|
||||||
g_autoptr (GError) error = NULL;
|
g_autoptr (GError) error = NULL;
|
||||||
|
|
||||||
|
if (template == NULL)
|
||||||
|
template = "plain";
|
||||||
|
|
||||||
dir = g_file_new_build_filename (g_get_user_data_dir (),
|
dir = g_file_new_build_filename (g_get_user_data_dir (),
|
||||||
"gnome-shell",
|
"gnome-shell",
|
||||||
"extensions",
|
"extensions",
|
||||||
@ -231,7 +234,7 @@ create_extension (const char *uuid, const char *name, const char *description)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!copy_extension_template ("plain", dir, &error))
|
if (!copy_extension_template (template, dir, &error))
|
||||||
{
|
{
|
||||||
g_printerr ("%s\n", error->message);
|
g_printerr ("%s\n", error->message);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -328,6 +331,7 @@ handle_create (int argc, char *argv[], gboolean do_help)
|
|||||||
g_autofree char *name = NULL;
|
g_autofree char *name = NULL;
|
||||||
g_autofree char *description = NULL;
|
g_autofree char *description = NULL;
|
||||||
g_autofree char *uuid = NULL;
|
g_autofree char *uuid = NULL;
|
||||||
|
g_autofree char *template = NULL;
|
||||||
gboolean interactive = FALSE;
|
gboolean interactive = FALSE;
|
||||||
gboolean list_templates = FALSE;
|
gboolean list_templates = FALSE;
|
||||||
GOptionEntry entries[] = {
|
GOptionEntry entries[] = {
|
||||||
@ -343,6 +347,10 @@ handle_create (int argc, char *argv[], gboolean do_help)
|
|||||||
.arg_description = _("DESCRIPTION"),
|
.arg_description = _("DESCRIPTION"),
|
||||||
.arg = G_OPTION_ARG_STRING, .arg_data = &description,
|
.arg = G_OPTION_ARG_STRING, .arg_data = &description,
|
||||||
.description = _("A short description of what the extension does") },
|
.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",
|
{ .long_name = "list-templates",
|
||||||
.arg = G_OPTION_ARG_NONE, .arg_data = &list_templates,
|
.arg = G_OPTION_ARG_NONE, .arg_data = &list_templates,
|
||||||
.flags = G_OPTION_FLAG_HIDDEN },
|
.flags = G_OPTION_FLAG_HIDDEN },
|
||||||
@ -403,5 +411,5 @@ handle_create (int argc, char *argv[], gboolean do_help)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return create_extension (uuid, name, description) ? 0 : 2;
|
return create_extension (uuid, name, description, template) ? 0 : 2;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user