After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 768737 - [review] lr/completion-2: Improve --complete-args
[review] lr/completion-2: Improve --complete-args
Status: RESOLVED FIXED
Product: NetworkManager
Classification: Platform
Component: nmcli
git master
Other Linux
: Normal normal
: ---
Assigned To: NetworkManager maintainer(s)
NetworkManager maintainer(s)
Depends on:
Blocks: nm-review
 
 
Reported: 2016-07-12 14:45 UTC by Lubomir Rintel
Modified: 2016-08-01 14:14 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Lubomir Rintel 2016-07-12 14:45:41 UTC
This extends coverage of the --complete-args functionality.

Notably missing:
 * -f option
 * actual nmcli-completion conversion to use --complete-args

https://cgit.freedesktop.org/NetworkManager/NetworkManager/log/?h=lr/completion-2
Comment 1 Beniamino Galvani 2016-07-19 20:04:25 UTC
> cli/device: add Wi-Fi access point completion functionality

+static void
+complete_aps (NMDevice **devices, const char *ifname,
+              const char *bssid_prefix, const char *ssid_prefix)

The function is not used at this point and thus this commit doesn't
compile with -Werror; please move it to the later commit that uses it.



> cli/device: add completion to wifi rescan subcommand

 do_device_wifi_rescan (NmCli *nmc, int argc, char **argv)
 ...
                        ifname = *argv;
+                       complete_device (devices, ifname, TRUE);

The completion here is done even if !nmc->complete.



> cli/device: add completion to wifi list subcommand
> cli/device: add completion to wifi connect subcommand
> cli/device: add completion to wifi hotspot subcommand

The same here.



> cli/connections: do connection completion in get_connection()

 static NMConnection *
 get_connection (NmCli *nmc, int *argc, char ***argv, int *pos, GError **error)
 {
 ...
+       if (*argc == 1)
+               nmc_complete_strings (**argv, "id", "uuid", "path", NULL);

We should also check nmc->complete, otherwise:
  $ nmcli connection up i
  id
  Error: unknown connection 'i'.
Comment 2 Lubomir Rintel 2016-07-22 14:28:54 UTC
Thanks. Updated the branch to address all the issues.
Comment 3 Beniamino Galvani 2016-07-27 08:47:58 UTC
LGTM (pushed a couple of fixups).
Comment 4 Francesco Giudici 2016-07-28 10:34:29 UTC
LGTM

one silly, minor-minor thing: in nmcli.h we have 4 enum types. All but one didn't had the comma after the final element. Now this branch makes that number even... maybe you want to add the comma to the final element to all:

--- a/clients/cli/nmcli.h
+++ b/clients/cli/nmcli.h
@@ -78,7 +78,7 @@ typedef enum {
        NMC_TERM_COLOR_BLUE    = 5,
        NMC_TERM_COLOR_MAGENTA = 6,
        NMC_TERM_COLOR_CYAN    = 7,
-       NMC_TERM_COLOR_WHITE   = 8
+       NMC_TERM_COLOR_WHITE   = 8,
 } NmcTermColor;
 
 typedef enum {
@@ -94,7 +94,7 @@ typedef enum {
 typedef enum {
        NMC_PRINT_TERSE = 0,
        NMC_PRINT_NORMAL = 1,
-       NMC_PRINT_PRETTY = 2
+       NMC_PRINT_PRETTY = 2,
 } NMCPrintOutput;
Comment 5 Lubomir Rintel 2016-08-01 14:14:35 UTC
(In reply to Francesco Giudici from comment #4)
> LGTM
> 
> one silly, minor-minor thing: in nmcli.h we have 4 enum types. All but one
> didn't had the comma after the final element. Now this branch makes that
> number even... maybe you want to add the comma to the final element to all:
> 
> --- a/clients/cli/nmcli.h
> +++ b/clients/cli/nmcli.h
> @@ -78,7 +78,7 @@ typedef enum {
>         NMC_TERM_COLOR_BLUE    = 5,
>         NMC_TERM_COLOR_MAGENTA = 6,
>         NMC_TERM_COLOR_CYAN    = 7,
> -       NMC_TERM_COLOR_WHITE   = 8
> +       NMC_TERM_COLOR_WHITE   = 8,
>  } NmcTermColor;
>  
>  typedef enum {
> @@ -94,7 +94,7 @@ typedef enum {
>  typedef enum {
>         NMC_PRINT_TERSE = 0,
>         NMC_PRINT_NORMAL = 1,
> -       NMC_PRINT_PRETTY = 2
> +       NMC_PRINT_PRETTY = 2,
>  } NMCPrintOutput;

I'm leaving it as it is. It most places we leave the comma in place, but I haven't touched those who don't and would prefer not to touch unrelated lines.

Merged