systemd-ac-power: convert to VERB_COMMAND
This commit is contained in:
+9
-23
@@ -1,13 +1,13 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "sd-json.h"
|
||||
|
||||
#include "battery-util.h"
|
||||
#include "build.h"
|
||||
#include "format-table.h"
|
||||
#include "help-util.h"
|
||||
#include "log.h"
|
||||
#include "main-func.h"
|
||||
#include "options.h"
|
||||
#include "string-util.h"
|
||||
#include "verbs.h"
|
||||
|
||||
static bool arg_verbose = false;
|
||||
|
||||
@@ -16,25 +16,11 @@ static enum {
|
||||
ACTION_LOW,
|
||||
} arg_action = ACTION_AC_POWER;
|
||||
|
||||
static int help(void) {
|
||||
int r;
|
||||
|
||||
_cleanup_(table_unrefp) Table *options = NULL;
|
||||
r = option_parser_get_help_table(&options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
help_cmdline("[OPTIONS...]");
|
||||
help_abstract("Report whether we are connected to an external power source.");
|
||||
|
||||
help_section("Options");
|
||||
r = table_print_or_warn(options);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
help_man_page_reference("systemd-ac-power", "1");
|
||||
return 0;
|
||||
}
|
||||
COMMAND(
|
||||
"systemd-ac-power\0",
|
||||
"Report whether we are connected to an external power source.",
|
||||
.man_pages = "systemd-ac-power.1\0",
|
||||
);
|
||||
|
||||
static int parse_argv(int argc, char *argv[]) {
|
||||
|
||||
@@ -46,7 +32,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
FOREACH_OPTION_OR_RETURN(c, &opts)
|
||||
switch (c) {
|
||||
OPTION_COMMON_HELP:
|
||||
return help();
|
||||
return command_print_help("systemd-ac-power");
|
||||
|
||||
OPTION_COMMON_VERSION:
|
||||
return version();
|
||||
|
||||
Reference in New Issue
Block a user