projects
/
project
/
ubus.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
libubus: Check if remove callback exists before call it
[project/ubus.git]
/
cli.c
diff --git
a/cli.c
b/cli.c
index
9e16bc8
..
6bfb44e
100644
(file)
--- a/
cli.c
+++ b/
cli.c
@@
-19,6
+19,7
@@
static struct blob_buf b;
static int timeout = 30;
static bool simple_output = false;
static struct blob_buf b;
static int timeout = 30;
static bool simple_output = false;
+static int verbose = 0;
static const char *format_type(void *priv, struct blob_attr *attr)
{
static const char *format_type(void *priv, struct blob_attr *attr)
{
@@
-26,6
+27,8
@@
static const char *format_type(void *priv, struct blob_attr *attr)
[BLOBMSG_TYPE_INT8] = "\"Boolean\"",
[BLOBMSG_TYPE_INT32] = "\"Integer\"",
[BLOBMSG_TYPE_STRING] = "\"String\"",
[BLOBMSG_TYPE_INT8] = "\"Boolean\"",
[BLOBMSG_TYPE_INT32] = "\"Integer\"",
[BLOBMSG_TYPE_STRING] = "\"String\"",
+ [BLOBMSG_TYPE_ARRAY] = "\"Array\"",
+ [BLOBMSG_TYPE_TABLE] = "\"Table\"",
};
const char *type = NULL;
int typeid;
};
const char *type = NULL;
int typeid;
@@
-48,7
+51,7
@@
static void receive_list_result(struct ubus_context *ctx, struct ubus_object_dat
char *s;
int rem;
char *s;
int rem;
- if (simple_output) {
+ if (simple_output
|| !verbose
) {
printf("%s\n", obj->path);
return;
}
printf("%s\n", obj->path);
return;
}
@@
-71,7
+74,7
@@
static void receive_call_result_data(struct ubus_request *req, int type, struct
if (!msg)
return;
if (!msg)
return;
- str = blobmsg_format_json_indent(msg, true, 0);
+ str = blobmsg_format_json_indent(msg, true,
simple_output ? -1 :
0);
printf("%s\n", str);
free(str);
}
printf("%s\n", str);
free(str);
}
@@
-189,6
+192,7
@@
static int usage(const char *prog)
" -s <socket>: Set the unix domain socket to connect to\n"
" -t <timeout>: Set the timeout (in seconds) for a command to complete\n"
" -S: Use simplified output (for scripts)\n"
" -s <socket>: Set the unix domain socket to connect to\n"
" -t <timeout>: Set the timeout (in seconds) for a command to complete\n"
" -S: Use simplified output (for scripts)\n"
+ " -v: More verbose output\n"
"\n"
"Commands:\n"
" - list [<path>] List objects\n"
"\n"
"Commands:\n"
" - list [<path>] List objects\n"
@@
-220,7
+224,7
@@
int main(int argc, char **argv)
progname = argv[0];
progname = argv[0];
- while ((ch = getopt(argc, argv, "s:t:S")) != -1) {
+ while ((ch = getopt(argc, argv, "
v
s:t:S")) != -1) {
switch (ch) {
case 's':
ubus_socket = optarg;
switch (ch) {
case 's':
ubus_socket = optarg;
@@
-231,6
+235,9
@@
int main(int argc, char **argv)
case 'S':
simple_output = true;
break;
case 'S':
simple_output = true;
break;
+ case 'v':
+ verbose++;
+ break;
default:
return usage(progname);
}
default:
return usage(progname);
}