diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2020-01-02 13:35:42 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2020-01-02 13:35:42 +0100 |
commit | 7303df70a900bef271044b7eaef35fcb3416a40f (patch) | |
tree | fa2727dbc15953603d6b39e8ffd8ce2306c7b238 /drminfo.c | |
parent | 7312a5fcacb82cd92c936846dca641d322600054 (diff) | |
download | drminfo-7303df70a900bef271044b7eaef35fcb3416a40f.tar.gz |
bash completion, fix drminfo logn getopt
Diffstat (limited to 'drminfo.c')
-rw-r--r-- | drminfo.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -21,6 +21,7 @@ #include "drmtools.h" #include "drm-lease.h" #include "logind.h" +#include "complete.h" static int ttycols = 80; @@ -460,6 +461,7 @@ static void usage(FILE *fp) enum { OPT_LONG_LEASE = 0x100, + OPT_LONG_COMP_BASH, }; struct option long_opts[] = { @@ -505,6 +507,10 @@ struct option long_opts[] = { .has_arg = false, .val = 'l', },{ + .name = "complete-bash", + .has_arg = false, + .val = OPT_LONG_COMP_BASH, + },{ /* --- with argument --- */ .name = "card", @@ -535,7 +541,7 @@ int main(int argc, char **argv) char *columns; for (;;) { - c = getopt(argc, argv, "hlaAmsopPfFrc:"); + c = getopt_long(argc, argv, "hlaAmsopPfFrc:", long_opts, NULL); if (c == -1) break; switch (c) { @@ -579,9 +585,12 @@ int main(int argc, char **argv) case 'f': format = true; break; - case 'L': + case OPT_LONG_LEASE: lease_fd = drm_lease(optarg); break; + case OPT_LONG_COMP_BASH: + complete_bash("drminfo", long_opts); + exit(0); case 'h': usage(stdout); exit(0); |