]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
ip: add new command line argument -json (mutually exclusive with -color)
authorJulien Fortin <julien@cumulusnetworks.com>
Thu, 17 Aug 2017 17:35:49 +0000 (10:35 -0700)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 18 Aug 2017 01:02:40 +0000 (18:02 -0700)
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
include/utils.h
ip/ip.c

index 6080b962fb41114ababb505104978a980a11ae65..565bda60097b5bdaf62e76538ec61998d556ae57 100644 (file)
@@ -20,6 +20,7 @@ extern int show_raw;
 extern int resolve_hosts;
 extern int oneline;
 extern int brief;
+extern int json;
 extern int timestamp;
 extern int timestamp_short;
 extern const char * _SL_;
diff --git a/ip/ip.c b/ip/ip.c
index 7c14a8ec18c0073125994d2459a68c4dff71a944..e66f69700105e82eb55a469b037aaf1107e15c42 100644 (file)
--- a/ip/ip.c
+++ b/ip/ip.c
@@ -33,6 +33,7 @@ int show_details;
 int resolve_hosts;
 int oneline;
 int brief;
+int json;
 int timestamp;
 const char *_SL_;
 int force;
@@ -258,6 +259,8 @@ int main(int argc, char **argv)
                        batch_file = argv[1];
                } else if (matches(opt, "-brief") == 0) {
                        ++brief;
+               } else if (matches(opt, "-json") == 0) {
+                       ++json;
                } else if (matches(opt, "-rcvbuf") == 0) {
                        unsigned int size;
 
@@ -292,6 +295,9 @@ int main(int argc, char **argv)
 
        _SL_ = oneline ? "\\" : "\n";
 
+       if (json)
+               check_if_color_enabled();
+
        if (batch_file)
                return batch(batch_file);