rfkill: add --output-all option

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2018-04-24 21:47:26 +01:00
parent ba1c9075f4
commit 4dfd172dd8
No known key found for this signature in database
GPG Key ID: A9553245FDE9B739
3 changed files with 15 additions and 1 deletions

View File

@ -36,6 +36,7 @@ _rfkill_module()
--json
--noheadings
--output
--output-all
--raw
--help
--version

View File

@ -34,6 +34,9 @@ Do not print a header line.
Specify which output columns to print. Use \-\-help to get a list of
available columns.
.TP
.B \-\-output\-all
Output all available columns.
.TP
\fB\-r\fR, \fB\-\-raw\fR
Use the raw output format.
.TP

View File

@ -579,6 +579,7 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" -J, --json use JSON output format\n"), stdout);
fputs(_(" -n, --noheadings don't print headings\n"), stdout);
fputs(_(" -o, --output <list> define which output columns to use\n"), stdout);
fputs(_(" --output-all output all columns\n"), stdout);
fputs(_(" -r, --raw use the raw output format\n"), stdout);
fputs(USAGE_SEPARATOR, stdout);
@ -609,12 +610,16 @@ static void __attribute__((__noreturn__)) usage(void)
int main(int argc, char **argv)
{
struct control ctrl = { 0 };
int c, act = ACT_LIST;
int c, act = ACT_LIST, list_all = 0;
char *outarg = NULL;
enum {
OPT_LIST_TYPES = CHAR_MAX + 1
};
static const struct option longopts[] = {
{ "json", no_argument, NULL, 'J' },
{ "noheadings", no_argument, NULL, 'n' },
{ "output", required_argument, NULL, 'o' },
{ "output-all", no_argument, NULL, OPT_LIST_TYPES },
{ "raw", no_argument, NULL, 'r' },
{ "version", no_argument, NULL, 'V' },
{ "help", no_argument, NULL, 'h' },
@ -644,6 +649,9 @@ int main(int argc, char **argv)
case 'o':
outarg = optarg;
break;
case OPT_LIST_TYPES:
list_all = 1;
break;
case 'r':
ctrl.raw = 1;
break;
@ -690,6 +698,8 @@ int main(int argc, char **argv)
columns[ncolumns++] = COL_ID;
columns[ncolumns++] = COL_TYPE;
columns[ncolumns++] = COL_DEVICE;
if (list_all)
columns[ncolumns++] = COL_DESC;
columns[ncolumns++] = COL_SOFT;
columns[ncolumns++] = COL_HARD;