aboutsummaryrefslogtreecommitdiffstats
path: root/drminfo.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2020-01-02 13:35:42 +0100
committerGerd Hoffmann <kraxel@redhat.com>2020-01-02 13:35:42 +0100
commit7303df70a900bef271044b7eaef35fcb3416a40f (patch)
treefa2727dbc15953603d6b39e8ffd8ce2306c7b238 /drminfo.c
parent7312a5fcacb82cd92c936846dca641d322600054 (diff)
downloaddrminfo-7303df70a900bef271044b7eaef35fcb3416a40f.tar.gz
bash completion, fix drminfo logn getopt
Diffstat (limited to 'drminfo.c')
-rw-r--r--drminfo.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drminfo.c b/drminfo.c
index ef9e259..e806417 100644
--- a/drminfo.c
+++ b/drminfo.c
@@ -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);