From patchwork Thu Aug 3 15:54:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Fortin X-Patchwork-Id: 797269 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=cumulusnetworks.com header.i=@cumulusnetworks.com header.b="To6r5Fwa"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xNZQj143bz9s7C for ; Fri, 4 Aug 2017 01:55:41 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751813AbdHCPzi (ORCPT ); Thu, 3 Aug 2017 11:55:38 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:38474 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751133AbdHCPzh (ORCPT ); Thu, 3 Aug 2017 11:55:37 -0400 Received: by mail-wm0-f48.google.com with SMTP id m85so19183290wma.1 for ; Thu, 03 Aug 2017 08:55:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cumulusnetworks.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6qh/zAdE6mdgF29w0mSBCrGgwtliEOkuvhEE9USBBqE=; b=To6r5FwaZjKAm/Wj0Oyz3R/pD8QL72wn5kTbX2vTKlCJT73JDVor2pNqXH075/yoAM cEPHZ7PB92A+hvfAuVtsEJ2OerTMbjLdm/M7/opICTpv2rWwmNX28qEdsWb/K0FiWxhj lis8U1iA/ASF4ntt911HUrWwiPsB2ZQNxwKyY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6qh/zAdE6mdgF29w0mSBCrGgwtliEOkuvhEE9USBBqE=; b=blrBXmBV5rmU3fwpD/wvXZGEhrtJZBxhJR79KX8QSAkEEkkYaNW1CtAfhGVLhUbGCN CkdQ9r24vhtyY/Fh7o9XP8869djDZXidCOWOkXkQeBxnIE1hrxtB9VQXOA08u13BxJHU 2otvaHgRD1ylXT5FDAi0Kl4x3U3B6vuKpaAqY1k91YLiflGMGIg/RLm0aayV+s7+Hjcx 8D+URnr96mJPbDNvKf4tdxp0wTYoujAXaZgfRIm+K4OGy3L9a6Rrpv+n+QkkfytXz1QM /9diiELL1vt9cNnzJL89oauJQgqJPSHR9EUI/D+QqXLdNwi1W1WmU+2dP3EpVJg5So0X Z+sQ== X-Gm-Message-State: AIVw111l6ruk5Oo9xOI+GJ0Y15PAoZ0Q7Rr6jOUtucizd163s9CPi0K4 0lcI1b8MqStqmf0FHoU= X-Received: by 10.28.87.6 with SMTP id l6mr1438184wmb.110.1501775735642; Thu, 03 Aug 2017 08:55:35 -0700 (PDT) Received: from localhost.localdomain (91-160-18-219.subs.proxad.net. [91.160.18.219]) by smtp.googlemail.com with ESMTPSA id d91sm2213309wma.23.2017.08.03.08.55.34 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 03 Aug 2017 08:55:35 -0700 (PDT) From: Julien Fortin X-Google-Original-From: Julien Fortin To: netdev@vger.kernel.org Cc: roopa@cumulusnetworks.com, nikolay@cumulusnetworks.com, dsa@cumulusnetworks.com, Julien Fortin Subject: [PATCH 02/27] ip: add new command line argument -json (mutually exclusive with -color) Date: Thu, 3 Aug 2017 17:54:50 +0200 Message-Id: <20170803155515.99226-3-julien@cumulusnetworks.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170803155515.99226-1-julien@cumulusnetworks.com> References: <20170803155515.99226-1-julien@cumulusnetworks.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Julien Fortin Signed-off-by: Julien Fortin --- include/utils.h | 1 + ip/ip.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/utils.h b/include/utils.h index 6080b962..565bda60 100644 --- a/include/utils.h +++ b/include/utils.h @@ -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 7c14a8ec..23399e37 100644 --- 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) + disable_color(); + if (batch_file) return batch(batch_file);