Add environment variables in help
Print the list of environment variables used by scrcpy in --help.
This commit is contained in:
parent
b5d4ec61fc
commit
f0361fc8b3
1 changed files with 43 additions and 0 deletions
|
@ -71,6 +71,11 @@ struct sc_shortcut {
|
||||||
const char *text;
|
const char *text;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct sc_envvar {
|
||||||
|
const char *name;
|
||||||
|
const char *text;
|
||||||
|
};
|
||||||
|
|
||||||
struct sc_getopt_adapter {
|
struct sc_getopt_adapter {
|
||||||
char *optstring;
|
char *optstring;
|
||||||
struct option *longopts;
|
struct option *longopts;
|
||||||
|
@ -585,6 +590,21 @@ static const struct sc_shortcut shortcuts[] = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const struct sc_envvar envvars[] = {
|
||||||
|
{
|
||||||
|
.name = "ADB",
|
||||||
|
.text = "Path to adb executable",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "SCRCPY_ICON_PATH",
|
||||||
|
.text = "Path to the program icon",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "SCRCPY_SERVER_PATH",
|
||||||
|
.text = "Path to the server binary",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
sc_getopt_adapter_create_optstring(void) {
|
sc_getopt_adapter_create_optstring(void) {
|
||||||
struct sc_strbuf buf;
|
struct sc_strbuf buf;
|
||||||
|
@ -804,6 +824,23 @@ print_shortcut(const struct sc_shortcut *shortcut, unsigned cols) {
|
||||||
free(text);
|
free(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_envvar(const struct sc_envvar *envvar, unsigned cols) {
|
||||||
|
assert(cols > 8); // sc_str_wrap_lines() requires indent < columns
|
||||||
|
assert(envvar->name);
|
||||||
|
assert(envvar->text);
|
||||||
|
|
||||||
|
printf("\n %s\n", envvar->name);
|
||||||
|
char *text = sc_str_wrap_lines(envvar->text, cols, 8);
|
||||||
|
if (!text) {
|
||||||
|
printf("<ERROR>\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%s\n", text);
|
||||||
|
free(text);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
scrcpy_print_usage(const char *arg0) {
|
scrcpy_print_usage(const char *arg0) {
|
||||||
#define SC_TERM_COLS_DEFAULT 80
|
#define SC_TERM_COLS_DEFAULT 80
|
||||||
|
@ -836,6 +873,12 @@ scrcpy_print_usage(const char *arg0) {
|
||||||
for (size_t i = 0; i < ARRAY_LEN(shortcuts); ++i) {
|
for (size_t i = 0; i < ARRAY_LEN(shortcuts); ++i) {
|
||||||
print_shortcut(&shortcuts[i], cols);
|
print_shortcut(&shortcuts[i], cols);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Print environment variables section
|
||||||
|
printf("\nEnvironment variables:\n");
|
||||||
|
for (size_t i = 0; i < ARRAY_LEN(envvars); ++i) {
|
||||||
|
print_envvar(&envvars[i], cols);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
|
Loading…
Reference in a new issue