udev/scsi_id: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and --introspect-cli is added. The abstract is changed to the imperative. There is no man page for this udev helper, so none is referenced.
This commit is contained in:
+13
-19
@@ -8,16 +8,15 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "sd-json.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "build.h"
|
||||
#include "device-nodes.h"
|
||||
#include "extract-word.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "format-table.h"
|
||||
#include "help-util.h"
|
||||
#include "main-func.h"
|
||||
#include "options.h"
|
||||
#include "parse-util.h"
|
||||
#include "scsi_id.h"
|
||||
#include "string-util.h"
|
||||
@@ -25,6 +24,7 @@
|
||||
#include "strxcpyx.h"
|
||||
#include "udev-util.h"
|
||||
#include "utf8.h"
|
||||
#include "verbs.h"
|
||||
|
||||
static bool all_good = false;
|
||||
static bool dev_specified = false;
|
||||
@@ -40,6 +40,12 @@ static char model_enc_str[256];
|
||||
static char revision_str[16];
|
||||
static char type_str[16];
|
||||
|
||||
COMMAND(
|
||||
"scsi_id\0",
|
||||
"Identify SCSI devices.",
|
||||
.argspec = "[DEVICE]\0",
|
||||
);
|
||||
|
||||
static void set_type(unsigned type_num, char *to, size_t len) {
|
||||
const char *type;
|
||||
|
||||
@@ -206,21 +212,6 @@ static int parse_page_code(const char *value, enum page_code *ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int help(void) {
|
||||
_cleanup_(table_unrefp) Table *options = NULL;
|
||||
int r;
|
||||
|
||||
r = option_parser_get_help_table(&options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
help_cmdline("[OPTION...] DEVICE");
|
||||
help_abstract("SCSI device identification.");
|
||||
help_section("Options");
|
||||
|
||||
return table_print_or_warn(options);
|
||||
}
|
||||
|
||||
static int set_options(int argc, char **argv, char *maj_min_dev) {
|
||||
assert(argc >= 0);
|
||||
assert(argv);
|
||||
@@ -232,7 +223,7 @@ static int set_options(int argc, char **argv, char *maj_min_dev) {
|
||||
switch (c) {
|
||||
|
||||
OPTION_COMMON_HELP:
|
||||
return help();
|
||||
return command_print_help("scsi_id");
|
||||
|
||||
OPTION_COMMON_VERSION_WITH_HIDDEN_V:
|
||||
return version();
|
||||
@@ -284,6 +275,9 @@ static int set_options(int argc, char **argv, char *maj_min_dev) {
|
||||
OPTION('x', "export", NULL, "Print values as environment keys"):
|
||||
export = true;
|
||||
break;
|
||||
|
||||
OPTION_COMMON_INTROSPECT_CLI:
|
||||
return introspect_cli(SD_JSON_FORMAT_OFF);
|
||||
}
|
||||
|
||||
char **args = option_parser_get_args(&opts);
|
||||
|
||||
@@ -32,6 +32,7 @@ INTROSPECTABLE=(
|
||||
portablectl
|
||||
resolvectl
|
||||
run0
|
||||
scsi_id
|
||||
storagectl
|
||||
systemd-ac-power
|
||||
systemd-analyze
|
||||
|
||||
Reference in New Issue
Block a user