mirror of
https://github.com/systemd/systemd.git
synced 2025-03-28 02:50:16 +03:00
machinectl: add --value option
This commit is contained in:
parent
f4046fe06f
commit
855005230b
@ -136,6 +136,13 @@
|
||||
(<literal>.</literal>).</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--value</option></term>
|
||||
|
||||
<listitem><para>When printing properties with <command>show</command>, only print the value,
|
||||
and skip the property name and <literal>=</literal>.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-l</option></term>
|
||||
<term><option>--full</option></term>
|
||||
|
@ -61,6 +61,7 @@
|
||||
|
||||
static char **arg_property = NULL;
|
||||
static bool arg_all = false;
|
||||
static bool arg_value = false;
|
||||
static bool arg_full = false;
|
||||
static bool arg_no_pager = false;
|
||||
static bool arg_legend = true;
|
||||
@ -680,7 +681,7 @@ static int show_machine_properties(sd_bus *bus, const char *path, bool *new_line
|
||||
|
||||
*new_line = true;
|
||||
|
||||
r = bus_print_all_properties(bus, "org.freedesktop.machine1", path, arg_property, arg_all);
|
||||
r = bus_print_all_properties(bus, "org.freedesktop.machine1", path, arg_property, arg_value, arg_all);
|
||||
if (r < 0)
|
||||
log_error_errno(r, "Could not get properties: %m");
|
||||
|
||||
@ -929,7 +930,7 @@ static int show_image_properties(sd_bus *bus, const char *path, bool *new_line)
|
||||
|
||||
*new_line = true;
|
||||
|
||||
r = bus_print_all_properties(bus, "org.freedesktop.machine1", path, arg_property, arg_all);
|
||||
r = bus_print_all_properties(bus, "org.freedesktop.machine1", path, arg_property, arg_value, arg_all);
|
||||
if (r < 0)
|
||||
log_error_errno(r, "Could not get properties: %m");
|
||||
|
||||
@ -2356,6 +2357,7 @@ static int help(int argc, char *argv[], void *userdata) {
|
||||
" -p --property=NAME Show only properties by this name\n"
|
||||
" -q --quiet Suppress output\n"
|
||||
" -a --all Show all properties, including empty ones\n"
|
||||
" --value When showing properties, only print the value\n"
|
||||
" -l --full Do not ellipsize output\n"
|
||||
" --kill-who=WHO Who to send signal to\n"
|
||||
" -s --signal=SIGNAL Which signal to send\n"
|
||||
@ -2418,6 +2420,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
ARG_VERSION = 0x100,
|
||||
ARG_NO_PAGER,
|
||||
ARG_NO_LEGEND,
|
||||
ARG_VALUE,
|
||||
ARG_KILL_WHO,
|
||||
ARG_READ_ONLY,
|
||||
ARG_MKDIR,
|
||||
@ -2434,6 +2437,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
{ "version", no_argument, NULL, ARG_VERSION },
|
||||
{ "property", required_argument, NULL, 'p' },
|
||||
{ "all", no_argument, NULL, 'a' },
|
||||
{ "value", no_argument, NULL, ARG_VALUE },
|
||||
{ "full", no_argument, NULL, 'l' },
|
||||
{ "no-pager", no_argument, NULL, ARG_NO_PAGER },
|
||||
{ "no-legend", no_argument, NULL, ARG_NO_LEGEND },
|
||||
@ -2485,6 +2489,10 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
arg_all = true;
|
||||
break;
|
||||
|
||||
case ARG_VALUE:
|
||||
arg_value = true;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
arg_full = true;
|
||||
break;
|
||||
|
@ -930,7 +930,7 @@ int bus_print_property(const char *name, sd_bus_message *property, bool value, b
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bus_print_all_properties(sd_bus *bus, const char *dest, const char *path, char **filter, bool all) {
|
||||
int bus_print_all_properties(sd_bus *bus, const char *dest, const char *path, char **filter, bool value, bool all) {
|
||||
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
int r;
|
||||
@ -970,7 +970,7 @@ int bus_print_all_properties(sd_bus *bus, const char *dest, const char *path, ch
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = bus_print_property(name, reply, false, all);
|
||||
r = bus_print_property(name, reply, value, all);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r == 0) {
|
||||
|
@ -79,7 +79,7 @@ int bus_connect_transport(BusTransport transport, const char *host, bool user, s
|
||||
int bus_connect_transport_systemd(BusTransport transport, const char *host, bool user, sd_bus **bus);
|
||||
|
||||
int bus_print_property(const char *name, sd_bus_message *property, bool value, bool all);
|
||||
int bus_print_all_properties(sd_bus *bus, const char *dest, const char *path, char **filter, bool all);
|
||||
int bus_print_all_properties(sd_bus *bus, const char *dest, const char *path, char **filter, bool value, bool all);
|
||||
|
||||
int bus_property_get_bool(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user