Another batch of conversions to COMMAND and additions of --introspect-cli (#43512)

This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-08-26 15:22:50 +02:00
committed by GitHub
34 changed files with 365 additions and 255 deletions
-27
View File
@@ -13,7 +13,6 @@
#include "path-util.h"
#include "process-util.h"
#include "string-util.h"
#include "strv.h"
int saved_argc = 0;
char **saved_argv = NULL;
@@ -69,32 +68,6 @@ bool invoked_by_systemd(void) {
return cached;
}
bool argv_looks_like_help(int argc, char **argv) {
char **l;
/* Scans the command line for indications the user asks for help. This is supposed to be called by
* tools that do not implement getopt()-style command line parsing because they are not primarily
* user-facing. Detects four ways of asking for help:
*
* 1. Passing zero arguments
* 2. Passing "help" as first argument
* 3. Passing --help as any argument
* 4. Passing -h as any argument
*/
assert(argc == 0 || argv);
if (argc <= 1)
return true;
if (streq_ptr(argv[1], "help"))
return true;
l = strv_skip(argv, 1);
return strv_contains(l, "--help") ||
strv_contains(l, "-h");
}
static int update_argv(const char name[], size_t l) {
static int can_do = -1;
int r;
-1
View File
@@ -10,7 +10,6 @@ void save_argc_argv(int argc, char **argv);
bool invoked_as(char *argv[], const char *token);
bool invoked_by_systemd(void) _const_;
bool argv_looks_like_help(int argc, char **argv);
int rename_process_full(const char *comm, const char *invocation);
static inline int rename_process(const char *name) {
+1
View File
@@ -37,6 +37,7 @@ int proc_cmdline_filter_pid1_args(char **argv, char ***ret) {
{ "no-pager", no_argument, },
{ "help", no_argument, },
{ "version", no_argument, },
{ "introspect-cli", no_argument, },
{ "dump-configuration-items", no_argument, },
{ "dump-bus-properties", no_argument, },
{ "bus-introspect", required_argument },