]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/service-util.c
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
6 #include "alloc-util.h"
8 #include "pretty-print.h"
9 #include "service-util.h"
10 #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("%1$s [OPTIONS...]\n"
22 "\nThis program takes no positional arguments.\n"
23 "\n%3$sOptions:%4$s\n"
24 " -h --help Show this help\n"
25 " --version Show package version\n"
27 "\nSee the %2$s for details.\n",
35 bus_introspect
? " --bus-introspect=PATH Write D-Bus XML introspection data\n" : "");
37 return 0; /* No further action */
40 int service_parse_argv(
42 const char *description
,
43 const BusObjectImplementation
* const* bus_objects
,
44 int argc
, char *argv
[]) {
51 static const struct option options
[] = {
52 { "help", no_argument
, NULL
, 'h' },
53 { "version", no_argument
, NULL
, ARG_VERSION
},
54 { "bus-introspect", required_argument
, NULL
, ARG_BUS_INTROSPECT
},
63 while ((c
= getopt_long(argc
, argv
, "h", options
, NULL
)) >= 0)
67 return help(argv
[0], service
, description
, bus_objects
);
72 case ARG_BUS_INTROSPECT
:
73 return bus_introspect_implementations(
86 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
),
87 "This program takes no arguments.");
89 return 1; /* Further action */