forked from Mirrors/flatpak-builder
Add more completions
parent
4e3149e88d
commit
8533f06dc0
|
@ -202,7 +202,6 @@ flatpak_builtin_add_remote (int argc, char **argv,
|
|||
g_autofree char *remote_url = NULL;
|
||||
const char *remote_name;
|
||||
const char *url_or_path;
|
||||
g_autofree char *prio_as_string = NULL;
|
||||
g_autoptr(GKeyFile) config = NULL;
|
||||
g_autoptr(GBytes) gpg_data = NULL;
|
||||
|
||||
|
@ -265,6 +264,32 @@ flatpak_builtin_add_remote (int argc, char **argv,
|
|||
return flatpak_dir_modify_remote (dir, remote_name, config, gpg_data, cancellable, error);
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_complete_add_remote (FlatpakCompletion *completion)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(FlatpakDir) dir = NULL;
|
||||
|
||||
context = g_option_context_new ("");
|
||||
g_option_context_add_main_entries (context, common_options, NULL);
|
||||
if (!flatpak_option_context_parse (context, add_options, &completion->argc, &completion->argv, 0, &dir, NULL, NULL))
|
||||
return FALSE;
|
||||
|
||||
switch (completion->argc)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
flatpak_complete_options (completion, global_entries);
|
||||
flatpak_complete_options (completion, common_options);
|
||||
flatpak_complete_options (completion, add_options);
|
||||
flatpak_complete_options (completion, user_entries);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_builtin_modify_remote (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
|
@ -300,3 +325,38 @@ flatpak_builtin_modify_remote (int argc, char **argv, GCancellable *cancellable,
|
|||
|
||||
return flatpak_dir_modify_remote (dir, remote_name, config, gpg_data, cancellable, error);
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_complete_modify_remote (FlatpakCompletion *completion)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(FlatpakDir) dir = NULL;
|
||||
int i;
|
||||
|
||||
context = g_option_context_new ("");
|
||||
g_option_context_add_main_entries (context, common_options, NULL);
|
||||
if (!flatpak_option_context_parse (context, modify_options, &completion->argc, &completion->argv, 0, &dir, NULL, NULL))
|
||||
return FALSE;
|
||||
|
||||
switch (completion->argc)
|
||||
{
|
||||
case 0:
|
||||
case 1: /* REMOTE */
|
||||
flatpak_complete_options (completion, global_entries);
|
||||
flatpak_complete_options (completion, common_options);
|
||||
flatpak_complete_options (completion, modify_options);
|
||||
flatpak_complete_options (completion, user_entries);
|
||||
|
||||
{
|
||||
g_auto(GStrv) remotes = flatpak_dir_list_remotes (dir, NULL, NULL);
|
||||
if (remotes == NULL)
|
||||
return FALSE;
|
||||
for (i = 0; remotes[i] != NULL; i++)
|
||||
flatpak_complete_word (completion, "%s ", remotes[i]);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -945,3 +945,32 @@ flatpak_builtin_build_bundle (int argc, char **argv, GCancellable *cancellable,
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_complete_build_bundle (FlatpakCompletion *completion)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
|
||||
context = g_option_context_new ("");
|
||||
|
||||
if (!flatpak_option_context_parse (context, options, &completion->argc, &completion->argv,
|
||||
FLATPAK_BUILTIN_FLAG_NO_DIR, NULL, NULL, NULL))
|
||||
return FALSE;
|
||||
|
||||
switch (completion->argc)
|
||||
{
|
||||
case 0:
|
||||
case 1: /* LOCATION */
|
||||
flatpak_complete_options (completion, global_entries);
|
||||
flatpak_complete_options (completion, options);
|
||||
|
||||
flatpak_complete_dir (completion);
|
||||
break;
|
||||
|
||||
case 2: /* FILENAME */
|
||||
flatpak_complete_file (completion);
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -462,3 +462,32 @@ out:
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_complete_build_export (FlatpakCompletion *completion)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
|
||||
context = g_option_context_new ("");
|
||||
|
||||
if (!flatpak_option_context_parse (context, options, &completion->argc, &completion->argv,
|
||||
FLATPAK_BUILTIN_FLAG_NO_DIR, NULL, NULL, NULL))
|
||||
return FALSE;
|
||||
|
||||
switch (completion->argc)
|
||||
{
|
||||
case 0:
|
||||
case 1: /* LOCATION */
|
||||
flatpak_complete_options (completion, global_entries);
|
||||
flatpak_complete_options (completion, options);
|
||||
|
||||
flatpak_complete_dir (completion);
|
||||
break;
|
||||
|
||||
case 2: /* DIR */
|
||||
flatpak_complete_dir (completion);
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -403,3 +403,33 @@ flatpak_builtin_build_finish (int argc, char **argv, GCancellable *cancellable,
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_complete_build_finish (FlatpakCompletion *completion)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(FlatpakContext) arg_context = NULL;
|
||||
|
||||
context = g_option_context_new ("");
|
||||
|
||||
arg_context = flatpak_context_new ();
|
||||
g_option_context_add_group (context, flatpak_context_get_options (arg_context));
|
||||
|
||||
if (!flatpak_option_context_parse (context, options, &completion->argc, &completion->argv,
|
||||
FLATPAK_BUILTIN_FLAG_NO_DIR, NULL, NULL, NULL))
|
||||
return FALSE;
|
||||
|
||||
switch (completion->argc)
|
||||
{
|
||||
case 0:
|
||||
case 1: /* DIR */
|
||||
flatpak_complete_options (completion, global_entries);
|
||||
flatpak_complete_options (completion, options);
|
||||
flatpak_context_complete (arg_context, completion);
|
||||
|
||||
flatpak_complete_dir (completion);
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -314,3 +314,32 @@ if (opt_oci)
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_complete_build_import (FlatpakCompletion *completion)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
|
||||
context = g_option_context_new ("");
|
||||
|
||||
if (!flatpak_option_context_parse (context, options, &completion->argc, &completion->argv,
|
||||
FLATPAK_BUILTIN_FLAG_NO_DIR, NULL, NULL, NULL))
|
||||
return FALSE;
|
||||
|
||||
switch (completion->argc)
|
||||
{
|
||||
case 0:
|
||||
case 1: /* LOCATION */
|
||||
flatpak_complete_options (completion, global_entries);
|
||||
flatpak_complete_options (completion, options);
|
||||
|
||||
flatpak_complete_dir (completion);
|
||||
break;
|
||||
|
||||
case 2: /* FILENAME */
|
||||
flatpak_complete_file (completion);
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -266,3 +266,98 @@ flatpak_builtin_build_init (int argc, char **argv, GCancellable *cancellable, GE
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_complete_build_init (FlatpakCompletion *completion)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(FlatpakDir) user_dir = NULL;
|
||||
g_autoptr(FlatpakDir) system_dir = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
int i;
|
||||
|
||||
context = g_option_context_new ("");
|
||||
|
||||
if (!flatpak_option_context_parse (context, options, &completion->argc, &completion->argv,
|
||||
FLATPAK_BUILTIN_FLAG_NO_DIR, NULL, NULL, NULL))
|
||||
return FALSE;
|
||||
|
||||
switch (completion->argc)
|
||||
{
|
||||
case 0:
|
||||
case 1: /* DIR */
|
||||
flatpak_complete_options (completion, global_entries);
|
||||
flatpak_complete_options (completion, options);
|
||||
|
||||
flatpak_complete_dir (completion);
|
||||
break;
|
||||
|
||||
case 2: /* APP */
|
||||
break;
|
||||
|
||||
case 3: /* RUNTIME */
|
||||
case 4: /* SDK */
|
||||
user_dir = flatpak_dir_get_user ();
|
||||
{
|
||||
g_auto(GStrv) refs = flatpak_dir_find_installed_refs (user_dir, NULL, NULL, opt_arch,
|
||||
FALSE, TRUE, &error);
|
||||
if (refs == NULL)
|
||||
flatpak_completion_debug ("find local refs error: %s", error->message);
|
||||
for (i = 0; refs != NULL && refs[i] != NULL; i++)
|
||||
{
|
||||
g_auto(GStrv) parts = flatpak_decompose_ref (refs[i], NULL);
|
||||
if (parts)
|
||||
flatpak_complete_word (completion, "%s ", parts[1]);
|
||||
}
|
||||
}
|
||||
|
||||
system_dir = flatpak_dir_get_system ();
|
||||
{
|
||||
g_auto(GStrv) refs = flatpak_dir_find_installed_refs (system_dir, NULL, NULL, opt_arch,
|
||||
FALSE, TRUE, &error);
|
||||
if (refs == NULL)
|
||||
flatpak_completion_debug ("find local refs error: %s", error->message);
|
||||
for (i = 0; refs != NULL && refs[i] != NULL; i++)
|
||||
{
|
||||
g_auto(GStrv) parts = flatpak_decompose_ref (refs[i], NULL);
|
||||
if (parts)
|
||||
flatpak_complete_word (completion, "%s ", parts[1]);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 5: /* BRANCH */
|
||||
user_dir = flatpak_dir_get_user ();
|
||||
{
|
||||
g_auto(GStrv) refs = flatpak_dir_find_installed_refs (user_dir, completion->argv[3], NULL, opt_arch,
|
||||
FALSE, TRUE, &error);
|
||||
if (refs == NULL)
|
||||
flatpak_completion_debug ("find local refs error: %s", error->message);
|
||||
for (i = 0; refs != NULL && refs[i] != NULL; i++)
|
||||
{
|
||||
g_auto(GStrv) parts = flatpak_decompose_ref (refs[i], NULL);
|
||||
if (parts)
|
||||
flatpak_complete_word (completion, "%s ", parts[3]);
|
||||
}
|
||||
}
|
||||
|
||||
system_dir = flatpak_dir_get_system ();
|
||||
{
|
||||
g_auto(GStrv) refs = flatpak_dir_find_installed_refs (system_dir, completion->argv[3], NULL, opt_arch,
|
||||
FALSE, TRUE, &error);
|
||||
if (refs == NULL)
|
||||
flatpak_completion_debug ("find local refs error: %s", error->message);
|
||||
for (i = 0; refs != NULL && refs[i] != NULL; i++)
|
||||
{
|
||||
g_auto(GStrv) parts = flatpak_decompose_ref (refs[i], NULL);
|
||||
if (parts)
|
||||
flatpak_complete_word (completion, "%s ", parts[3]);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -115,3 +115,34 @@ flatpak_builtin_build_sign (int argc, char **argv, GCancellable *cancellable, GE
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_complete_build_sign (FlatpakCompletion *completion)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
|
||||
context = g_option_context_new ("");
|
||||
|
||||
if (!flatpak_option_context_parse (context, options, &completion->argc, &completion->argv,
|
||||
FLATPAK_BUILTIN_FLAG_NO_DIR, NULL, NULL, NULL))
|
||||
return FALSE;
|
||||
|
||||
switch (completion->argc)
|
||||
{
|
||||
case 0:
|
||||
case 1: /* LOCATION */
|
||||
flatpak_complete_options (completion, global_entries);
|
||||
flatpak_complete_options (completion, options);
|
||||
|
||||
flatpak_complete_dir (completion);
|
||||
break;
|
||||
|
||||
case 2: /* ID */
|
||||
break;
|
||||
|
||||
case 3: /* BRANCH */
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -233,3 +233,28 @@ flatpak_builtin_build (int argc, char **argv, GCancellable *cancellable, GError
|
|||
/* Not actually reached... */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_complete_build (FlatpakCompletion *completion)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
|
||||
context = g_option_context_new ("");
|
||||
|
||||
if (!flatpak_option_context_parse (context, options, &completion->argc, &completion->argv,
|
||||
FLATPAK_BUILTIN_FLAG_NO_DIR, NULL, NULL, NULL))
|
||||
return FALSE;
|
||||
|
||||
switch (completion->argc)
|
||||
{
|
||||
case 0:
|
||||
case 1: /* DIR */
|
||||
flatpak_complete_options (completion, global_entries);
|
||||
flatpak_complete_options (completion, options);
|
||||
|
||||
flatpak_complete_dir (completion);
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -63,3 +63,36 @@ flatpak_builtin_delete_remote (int argc, char **argv, GCancellable *cancellable,
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_complete_delete_remote (FlatpakCompletion *completion)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(FlatpakDir) dir = NULL;
|
||||
int i;
|
||||
|
||||
context = g_option_context_new ("");
|
||||
if (!flatpak_option_context_parse (context, delete_options, &completion->argc, &completion->argv, 0, &dir, NULL, NULL))
|
||||
return FALSE;
|
||||
|
||||
switch (completion->argc)
|
||||
{
|
||||
case 0:
|
||||
case 1: /* REMOTE */
|
||||
flatpak_complete_options (completion, global_entries);
|
||||
flatpak_complete_options (completion, delete_options);
|
||||
flatpak_complete_options (completion, user_entries);
|
||||
|
||||
{
|
||||
g_auto(GStrv) remotes = flatpak_dir_list_remotes (dir, NULL, NULL);
|
||||
if (remotes == NULL)
|
||||
return FALSE;
|
||||
for (i = 0; remotes[i] != NULL; i++)
|
||||
flatpak_complete_word (completion, "%s ", remotes[i]);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -184,3 +184,28 @@ flatpak_builtin_export_file (int argc, char **argv,
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_complete_export_file (FlatpakCompletion *completion)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
|
||||
context = g_option_context_new ("");
|
||||
|
||||
if (!flatpak_option_context_parse (context, options, &completion->argc, &completion->argv,
|
||||
FLATPAK_BUILTIN_FLAG_NO_DIR, NULL, NULL, NULL))
|
||||
return FALSE;
|
||||
|
||||
switch (completion->argc)
|
||||
{
|
||||
case 0:
|
||||
case 1: /* FILE */
|
||||
flatpak_complete_options (completion, global_entries);
|
||||
flatpak_complete_options (completion, options);
|
||||
|
||||
flatpak_complete_file (completion);
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -173,7 +173,6 @@ flatpak_complete_info (FlatpakCompletion *completion)
|
|||
g_autoptr(FlatpakDir) user_dir = NULL;
|
||||
g_autoptr(FlatpakDir) system_dir = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
g_auto(GStrv) refs = NULL;
|
||||
int i;
|
||||
|
||||
context = g_option_context_new ("");
|
||||
|
|
|
@ -204,9 +204,7 @@ flatpak_builtin_install (int argc, char **argv, GCancellable *cancellable, GErro
|
|||
const char *name;
|
||||
const char *branch = NULL;
|
||||
g_autofree char *ref = NULL;
|
||||
g_autofree char *installed_ref = NULL;
|
||||
gboolean is_app;
|
||||
g_autoptr(GError) my_error = NULL;
|
||||
g_autoptr(GFile) deploy_base = NULL;
|
||||
|
||||
context = g_option_context_new ("REPOSITORY NAME [BRANCH] - Install an application or runtime");
|
||||
|
|
|
@ -147,3 +147,27 @@ flatpak_builtin_list_remotes (int argc, char **argv, GCancellable *cancellable,
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_complete_list_remotes (FlatpakCompletion *completion)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(FlatpakDir) dir = NULL;
|
||||
|
||||
context = g_option_context_new ("");
|
||||
if (!flatpak_option_context_parse (context, options, &completion->argc, &completion->argv, 0, &dir, NULL, NULL))
|
||||
return FALSE;
|
||||
|
||||
switch (completion->argc)
|
||||
{
|
||||
case 0:
|
||||
case 1: /* REMOTE */
|
||||
flatpak_complete_options (completion, global_entries);
|
||||
flatpak_complete_options (completion, options);
|
||||
flatpak_complete_options (completion, user_entries);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -145,3 +145,36 @@ flatpak_builtin_ls_remote (int argc, char **argv, GCancellable *cancellable, GEr
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_complete_ls_remote (FlatpakCompletion *completion)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(FlatpakDir) dir = NULL;
|
||||
int i;
|
||||
|
||||
context = g_option_context_new ("");
|
||||
if (!flatpak_option_context_parse (context, options, &completion->argc, &completion->argv, 0, &dir, NULL, NULL))
|
||||
return FALSE;
|
||||
|
||||
switch (completion->argc)
|
||||
{
|
||||
case 0:
|
||||
case 1: /* REMOTE */
|
||||
flatpak_complete_options (completion, global_entries);
|
||||
flatpak_complete_options (completion, options);
|
||||
flatpak_complete_options (completion, user_entries);
|
||||
|
||||
{
|
||||
g_auto(GStrv) remotes = flatpak_dir_list_remotes (dir, NULL, NULL);
|
||||
if (remotes == NULL)
|
||||
return FALSE;
|
||||
for (i = 0; remotes[i] != NULL; i++)
|
||||
flatpak_complete_word (completion, "%s ", remotes[i]);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -85,3 +85,56 @@ flatpak_builtin_make_current_app (int argc, char **argv, GCancellable *cancellab
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_complete_make_current_app (FlatpakCompletion *completion)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(FlatpakDir) dir = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
g_auto(GStrv) refs = NULL;
|
||||
int i;
|
||||
|
||||
context = g_option_context_new ("");
|
||||
if (!flatpak_option_context_parse (context, options, &completion->argc, &completion->argv, 0, &dir, NULL, NULL))
|
||||
return FALSE;
|
||||
|
||||
switch (completion->argc)
|
||||
{
|
||||
case 0:
|
||||
case 1: /* NAME */
|
||||
flatpak_complete_options (completion, global_entries);
|
||||
flatpak_complete_options (completion, options);
|
||||
flatpak_complete_options (completion, user_entries);
|
||||
|
||||
refs = flatpak_dir_find_installed_refs (dir, NULL, NULL, opt_arch,
|
||||
TRUE, FALSE, &error);
|
||||
if (refs == NULL)
|
||||
flatpak_completion_debug ("find installed refs error: %s", error->message);
|
||||
for (i = 0; refs != NULL && refs[i] != NULL; i++)
|
||||
{
|
||||
g_auto(GStrv) parts = flatpak_decompose_ref (refs[i], NULL);
|
||||
if (parts)
|
||||
flatpak_complete_word (completion, "%s ", parts[1]);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: /* Branch */
|
||||
refs = flatpak_dir_find_installed_refs (dir, completion->argv[1], NULL, opt_arch,
|
||||
TRUE, FALSE, &error);
|
||||
if (refs == NULL)
|
||||
flatpak_completion_debug ("find installed refs error: %s", error->message);
|
||||
for (i = 0; refs != NULL && refs[i] != NULL; i++)
|
||||
{
|
||||
g_auto(GStrv) parts = flatpak_decompose_ref (refs[i], NULL);
|
||||
if (parts)
|
||||
flatpak_complete_word (completion, "%s ", parts[3]);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -92,3 +92,65 @@ flatpak_builtin_override (int argc, char **argv, GCancellable *cancellable, GErr
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_complete_override (FlatpakCompletion *completion)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
g_autoptr(FlatpakDir) user_dir = NULL;
|
||||
g_autoptr(FlatpakDir) system_dir = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
int i;
|
||||
g_autoptr(FlatpakContext) arg_context = NULL;
|
||||
|
||||
context = g_option_context_new ("");
|
||||
|
||||
arg_context = flatpak_context_new ();
|
||||
g_option_context_add_group (context, flatpak_context_get_options (arg_context));
|
||||
|
||||
if (!flatpak_option_context_parse (context, options, &completion->argc, &completion->argv,
|
||||
FLATPAK_BUILTIN_FLAG_NO_DIR, NULL, NULL, NULL))
|
||||
return FALSE;
|
||||
|
||||
switch (completion->argc)
|
||||
{
|
||||
case 0:
|
||||
case 1: /* NAME */
|
||||
flatpak_complete_options (completion, global_entries);
|
||||
flatpak_complete_options (completion, options);
|
||||
flatpak_context_complete (arg_context, completion);
|
||||
|
||||
user_dir = flatpak_dir_get_user ();
|
||||
{
|
||||
g_auto(GStrv) refs = flatpak_dir_find_installed_refs (user_dir, NULL, NULL, NULL,
|
||||
TRUE, FALSE, &error);
|
||||
if (refs == NULL)
|
||||
flatpak_completion_debug ("find local refs error: %s", error->message);
|
||||
for (i = 0; refs != NULL && refs[i] != NULL; i++)
|
||||
{
|
||||
g_auto(GStrv) parts = flatpak_decompose_ref (refs[i], NULL);
|
||||
if (parts)
|
||||
flatpak_complete_word (completion, "%s ", parts[1]);
|
||||
}
|
||||
}
|
||||
|
||||
system_dir = flatpak_dir_get_system ();
|
||||
{
|
||||
g_auto(GStrv) refs = flatpak_dir_find_installed_refs (system_dir, NULL, NULL, NULL,
|
||||
TRUE, FALSE, &error);
|
||||
if (refs == NULL)
|
||||
flatpak_completion_debug ("find local refs error: %s", error->message);
|
||||
for (i = 0; refs != NULL && refs[i] != NULL; i++)
|
||||
{
|
||||
g_auto(GStrv) parts = flatpak_decompose_ref (refs[i], NULL);
|
||||
if (parts)
|
||||
flatpak_complete_word (completion, "%s ", parts[1]);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -214,3 +214,29 @@ flatpak_builtin_build_update_repo (int argc, char **argv,
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
flatpak_complete_build_update_repo (FlatpakCompletion *completion)
|
||||
{
|
||||
g_autoptr(GOptionContext) context = NULL;
|
||||
|
||||
context = g_option_context_new ("");
|
||||
|
||||
if (!flatpak_option_context_parse (context, options, &completion->argc, &completion->argv,
|
||||
FLATPAK_BUILTIN_FLAG_NO_DIR, NULL, NULL, NULL))
|
||||
return FALSE;
|
||||
|
||||
switch (completion->argc)
|
||||
{
|
||||
case 0:
|
||||
case 1: /* LOCATION */
|
||||
flatpak_complete_options (completion, global_entries);
|
||||
flatpak_complete_options (completion, options);
|
||||
|
||||
flatpak_complete_dir (completion);
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ flatpak_complete_uninstall (FlatpakCompletion *completion)
|
|||
refs = flatpak_dir_find_installed_refs (dir, NULL, NULL, opt_arch,
|
||||
opt_app, opt_runtime, &error);
|
||||
if (refs == NULL)
|
||||
flatpak_completion_debug ("find local refs error: %s", error->message);
|
||||
flatpak_completion_debug ("find installed refs error: %s", error->message);
|
||||
for (i = 0; refs != NULL && refs[i] != NULL; i++)
|
||||
{
|
||||
g_auto(GStrv) parts = flatpak_decompose_ref (refs[i], NULL);
|
||||
|
@ -135,7 +135,7 @@ flatpak_complete_uninstall (FlatpakCompletion *completion)
|
|||
refs = flatpak_dir_find_installed_refs (dir, completion->argv[1], NULL, opt_arch,
|
||||
opt_app, opt_runtime, &error);
|
||||
if (refs == NULL)
|
||||
flatpak_completion_debug ("find remote refs error: %s", error->message);
|
||||
flatpak_completion_debug ("find installed refs error: %s", error->message);
|
||||
for (i = 0; refs != NULL && refs[i] != NULL; i++)
|
||||
{
|
||||
g_auto(GStrv) parts = flatpak_decompose_ref (refs[i], NULL);
|
||||
|
|
|
@ -60,27 +60,27 @@ static FlatpakCommand commands[] = {
|
|||
|
||||
{ "\n Running applications" },
|
||||
{ "run", "Run an application", flatpak_builtin_run, flatpak_complete_run },
|
||||
{ "override", "Override permissions for an application", flatpak_builtin_override },
|
||||
{ "export-file", "Grant an application access to a specific file", flatpak_builtin_export_file},
|
||||
{ "make-current", "Specify default version to run", flatpak_builtin_make_current_app},
|
||||
{ "override", "Override permissions for an application", flatpak_builtin_override, flatpak_complete_override},
|
||||
{ "export-file", "Grant an application access to a specific file", flatpak_builtin_export_file, flatpak_complete_export_file},
|
||||
{ "make-current", "Specify default version to run", flatpak_builtin_make_current_app, flatpak_complete_make_current_app},
|
||||
{ "enter", "Enter the namespace of a running application", flatpak_builtin_enter },
|
||||
|
||||
{ "\n Manage remote repositories" },
|
||||
{ "remote-add", "Add a new remote repository (by URL)", flatpak_builtin_add_remote },
|
||||
{ "remote-modify", "Modify properties of a configured remote", flatpak_builtin_modify_remote},
|
||||
{ "remote-delete", "Delete a configured remote", flatpak_builtin_delete_remote},
|
||||
{ "remote-list", "List all configured remotes", flatpak_builtin_list_remotes},
|
||||
{ "remote-ls", "List contents of a configured remote", flatpak_builtin_ls_remote },
|
||||
{ "remote-add", "Add a new remote repository (by URL)", flatpak_builtin_add_remote, flatpak_complete_add_remote },
|
||||
{ "remote-modify", "Modify properties of a configured remote", flatpak_builtin_modify_remote, flatpak_complete_modify_remote },
|
||||
{ "remote-delete", "Delete a configured remote", flatpak_builtin_delete_remote, flatpak_complete_delete_remote },
|
||||
{ "remote-list", "List all configured remotes", flatpak_builtin_list_remotes, flatpak_complete_list_remotes },
|
||||
{ "remote-ls", "List contents of a configured remote", flatpak_builtin_ls_remote, flatpak_complete_ls_remote },
|
||||
|
||||
{ "\n Build applications" },
|
||||
{ "build-init", "Initialize a directory for building", flatpak_builtin_build_init },
|
||||
{ "build", "Run a build command inside the build dir", flatpak_builtin_build },
|
||||
{ "build-finish", "Finish a build dir for export", flatpak_builtin_build_finish },
|
||||
{ "build-export", "Export a build dir to a repository", flatpak_builtin_build_export },
|
||||
{ "build-bundle", "Create a bundle file from a build directory", flatpak_builtin_build_bundle },
|
||||
{ "build-import-bundle", "Import a bundle file", flatpak_builtin_build_import },
|
||||
{ "build-sign", "Sign an application or runtime", flatpak_builtin_build_sign },
|
||||
{ "build-update-repo", "Update the summary file in a repository", flatpak_builtin_build_update_repo },
|
||||
{ "build-init", "Initialize a directory for building", flatpak_builtin_build_init, flatpak_complete_build_init },
|
||||
{ "build", "Run a build command inside the build dir", flatpak_builtin_build, flatpak_complete_build },
|
||||
{ "build-finish", "Finish a build dir for export", flatpak_builtin_build_finish, flatpak_complete_build_finish },
|
||||
{ "build-export", "Export a build dir to a repository", flatpak_builtin_build_export, flatpak_complete_build_export },
|
||||
{ "build-bundle", "Create a bundle file from a build directory", flatpak_builtin_build_bundle, flatpak_complete_build_bundle },
|
||||
{ "build-import-bundle", "Import a bundle file", flatpak_builtin_build_import, flatpak_complete_build_import },
|
||||
{ "build-sign", "Sign an application or runtime", flatpak_builtin_build_sign, flatpak_complete_build_sign },
|
||||
{ "build-update-repo", "Update the summary file in a repository", flatpak_builtin_build_update_repo, flatpak_complete_build_update_repo },
|
||||
|
||||
{ NULL }
|
||||
};
|
||||
|
@ -354,7 +354,6 @@ complete (int argc,
|
|||
char **argv)
|
||||
{
|
||||
FlatpakCommand *command;
|
||||
g_autofree char *initial_completion_line = NULL;
|
||||
FlatpakCompletion *completion;
|
||||
const char *command_name = NULL;
|
||||
|
||||
|
|
|
@ -3987,9 +3987,7 @@ flatpak_dir_find_remote_refs (FlatpakDir *self,
|
|||
GError **error)
|
||||
{
|
||||
g_autofree char *refspec_prefix = NULL;
|
||||
g_autofree char *remote_ref = NULL;
|
||||
g_autoptr(GHashTable) remote_refs = NULL;
|
||||
g_autoptr(GError) my_error = NULL;
|
||||
GPtrArray *matched_refs;
|
||||
|
||||
if (!flatpak_dir_ensure_repo (self, NULL, error))
|
||||
|
@ -4111,9 +4109,7 @@ flatpak_dir_find_installed_refs (FlatpakDir *self,
|
|||
gboolean runtime,
|
||||
GError **error)
|
||||
{
|
||||
g_autofree char *local_ref = NULL;
|
||||
g_autoptr(GHashTable) local_refs = NULL;
|
||||
g_autoptr(GError) my_error = NULL;
|
||||
GPtrArray *matched_refs;
|
||||
|
||||
local_refs = flatpak_dir_get_all_installed_refs (self, app, runtime, error);
|
||||
|
|
|
@ -3080,6 +3080,20 @@ is_word_separator (char c)
|
|||
return g_ascii_isspace (c);
|
||||
}
|
||||
|
||||
void
|
||||
flatpak_complete_file (FlatpakCompletion *completion)
|
||||
{
|
||||
flatpak_completion_debug ("completing FILE");
|
||||
g_print ("%s\n", "__FLATPAK_FILE");
|
||||
}
|
||||
|
||||
void
|
||||
flatpak_complete_dir (FlatpakCompletion *completion)
|
||||
{
|
||||
flatpak_completion_debug ("completing DIR");
|
||||
g_print ("%s\n", "__FLATPAK_DIR");
|
||||
}
|
||||
|
||||
void
|
||||
flatpak_complete_word (FlatpakCompletion *completion,
|
||||
char *format, ...)
|
||||
|
@ -3144,6 +3158,10 @@ flatpak_complete_options (FlatpakCompletion *completion,
|
|||
for (i = 0; flatpak_context_sockets[i] != NULL; i++)
|
||||
flatpak_complete_word (completion, "%s%s ", prefix, flatpak_context_sockets[i]);
|
||||
}
|
||||
else if (strcmp (e->arg_description, "FILE") == 0)
|
||||
{
|
||||
flatpak_complete_file (completion);
|
||||
}
|
||||
else
|
||||
flatpak_complete_word (completion, "%s", prefix);
|
||||
}
|
||||
|
|
|
@ -374,6 +374,8 @@ FlatpakCompletion *flatpak_completion_new (const char *arg_line,
|
|||
void flatpak_complete_word (FlatpakCompletion *completion,
|
||||
char *format,
|
||||
...);
|
||||
void flatpak_complete_file (FlatpakCompletion *completion);
|
||||
void flatpak_complete_dir (FlatpakCompletion *completion);
|
||||
void flatpak_complete_options (FlatpakCompletion *completion,
|
||||
GOptionEntry *entries);
|
||||
void flatpak_completion_free (FlatpakCompletion *completion);
|
||||
|
|
|
@ -6,7 +6,28 @@
|
|||
__flatpak() {
|
||||
local IFS=$'\n'
|
||||
local cur=`_get_cword :`
|
||||
COMPREPLY=($(flatpak complete "${COMP_LINE}" "${COMP_POINT}" "${cur}"))
|
||||
RES=($(flatpak complete "${COMP_LINE}" "${COMP_POINT}" "${cur}"))
|
||||
|
||||
COMPREPLY=()
|
||||
for i in "${!RES[@]}"; do
|
||||
if [[ "${RES[$i]}" = "__FLATPAK_FILE" ]]; then
|
||||
if [[ "${cur}" = "=" ]]; then
|
||||
CUR=""
|
||||
else
|
||||
CUR="${cur}"
|
||||
fi
|
||||
COMPREPLY=("${COMPREPLY[@]}" $(compgen -f -- "${CUR}") )
|
||||
elif [[ "${RES[$i]}" = "__FLATPAK_DIR" ]]; then
|
||||
if [[ "${cur}" = "=" ]]; then
|
||||
CUR=""
|
||||
else
|
||||
CUR="${cur}"
|
||||
fi
|
||||
COMPREPLY=("${COMPREPLY[@]}" $(compgen -d -- "${CUR}") )
|
||||
else
|
||||
COMPREPLY=("${COMPREPLY[@]}" "${RES[$i]}")
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
####################################################################################################
|
||||
|
|
Loading…
Reference in New Issue