]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/service-util.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
6 #include "alloc-util.h"
7 #include "pretty-print.h"
8 #include "service-util.h"
9 #include "terminal-util.h"
12 static int help(const char *program_path
, const char *service
, const char *description
, bool bus_introspect
) {
13 _cleanup_free_
char *link
= NULL
;
16 r
= terminal_urlify_man(service
, "8", &link
);
20 printf("%s [OPTIONS...]\n\n"
22 "This program takes no positional arguments.\n\n"
24 " -h --help Show this help\n"
25 " --version Show package version\n"
26 " --bus-introspect=PATH Write D-Bus XML introspection data\n"
27 "\nSee the %s for details.\n"
29 , ansi_highlight(), description
, ansi_normal()
30 , ansi_underline(), ansi_normal()
34 return 0; /* No further action */
37 int service_parse_argv(
39 const char *description
,
40 const BusObjectImplementation
* const* bus_objects
,
41 int argc
, char *argv
[]) {
48 static const struct option options
[] = {
49 { "help", no_argument
, NULL
, 'h' },
50 { "version", no_argument
, NULL
, ARG_VERSION
},
51 { "bus-introspect", required_argument
, NULL
, ARG_BUS_INTROSPECT
},
60 while ((c
= getopt_long(argc
, argv
, "h", options
, NULL
)) >= 0)
64 return help(argv
[0], service
, description
, bus_objects
);
69 case ARG_BUS_INTROSPECT
:
70 return bus_introspect_implementations(
79 assert_not_reached("Unknown option code.");
83 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
),
84 "This program takes no arguments.");
86 return 1; /* Further action */