From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ci-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id F1711432CA;
	Tue,  7 Nov 2023 21:32:02 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id EB94142D2E;
	Tue,  7 Nov 2023 21:32:02 +0100 (CET)
Received: from us-smtp-delivery-124.mimecast.com
 (us-smtp-delivery-124.mimecast.com [170.10.133.124])
 by mails.dpdk.org (Postfix) with ESMTP id E55E942D2E
 for <ci@dpdk.org>; Tue,  7 Nov 2023 21:32:01 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;
 s=mimecast20190719; t=1699389121;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=R2RFGZkSy2M4Gb34kLHOqTLK9NspfeUeenjvSQm/V2Y=;
 b=gv+VX7m4zQ5atRXTggQGWd/IaDwNGY/95pPLc3lEDH4EmCy5AL/Q/4WXj6ix0HW+VK1Gg6
 PtbOIzjFfqkUzXwwg072eMT31hjItHmzFwVfa+AP5/BZ/DBz67Z/RgpkeLYdXAQs8v4Ul+
 ClDz/nkCtRCi1V0mjbiCt18/NMGV1fg=
Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com
 [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS
 (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id
 us-mta-596-HIqCJg-hNraetBJk-oQwVQ-1; Tue, 07 Nov 2023 15:31:59 -0500
X-MC-Unique: HIqCJg-hNraetBJk-oQwVQ-1
Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com
 [10.11.54.5])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
 (No client certificate requested)
 by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4444E101A53B;
 Tue,  7 Nov 2023 20:31:59 +0000 (UTC)
Received: from RHTPC1VM0NT.redhat.com (unknown [10.22.33.168])
 by smtp.corp.redhat.com (Postfix) with ESMTP id 1180119E93;
 Tue,  7 Nov 2023 20:31:59 +0000 (UTC)
From: Aaron Conole <aconole@redhat.com>
To: ci@dpdk.org
Cc: Michael Santana <msantana@redhat.com>,
 David Marchand <dmarchan@redhat.com>,
 Thomas Monjalon <thomas@monjalon.net>, Patrick Robb <probb@iol.unh.edu>,
 Dumitru Ceara <dceara@redhat.com>
Subject: [RFC v2 1/3] pw_mon: improve command line options
Date: Tue,  7 Nov 2023 15:31:56 -0500
Message-ID: <20231107203158.1261199-2-aconole@redhat.com>
In-Reply-To: <20231107203158.1261199-1-aconole@redhat.com>
References: <20231107203158.1261199-1-aconole@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5
X-Mimecast-Spam-Score: 0
X-Mimecast-Originator: redhat.com
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="US-ASCII"; x-default=true
X-BeenThere: ci@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK CI discussions <ci.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/ci>,
 <mailto:ci-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/ci/>
List-Post: <mailto:ci@dpdk.org>
List-Help: <mailto:ci-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/ci>,
 <mailto:ci-request@dpdk.org?subject=subscribe>
Errors-To: ci-bounces@dpdk.org

In the future, we'll use this to add support for passing opts into some parts
of pw_mon.

Signed-off-by: Aaron Conole <aconole@redhat.com>
---
 pw_mon | 65 +++++++++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 51 insertions(+), 14 deletions(-)

diff --git a/pw_mon b/pw_mon
index 28feb8b..da4b9a9 100755
--- a/pw_mon
+++ b/pw_mon
@@ -21,34 +21,71 @@
 
 [ -f "${HOME}/.pwmon-rc" ] && source "${HOME}/.pwmon-rc"
 
-if [ "$1" != "" ]; then
-    pw_project="$1"
-    shift
+if [ "$1" != ""  ]; then
+    if ! echo "$1" | grep -q -s -E ^-- ; then
+        pw_project="$1"
+        shift
+    fi
 fi
 
 if [ "$1" != "" ]; then
-    pw_instance="$1"
-    shift
-fi
-
-if [ "X$pw_instance" == "X" -o "X$pw_project" == "X" ]; then
-   echo "ERROR: Patchwork instance and project are unset."
-   echo "Please setup ${HOME}/.pwmon-rc and set pw_project "
-   echo "(or pass it as an argument)."
-   echo "Also either setup pw_instance or pass it as an argument."
-   exit 1
+    if ! echo "$1" | grep -q -s -E ^-- ; then
+        pw_instance="$1"
+        shift
+    fi
 fi
 
 userpw=""
 
 if [ "$1" != "" ]; then
-    pw_credential="$1"
+    if ! echo "$1" | grep -q -s -E ^-- ; then
+        pw_credential="$1"
+        shift
+    fi
 fi
 
+
+while [ "$1" != "" ]; do
+    if echo "$1" | grep -q -s -E ^--pw-project= ; then
+        pw_project=$(echo "$1" | sed s/^--pw-project=//)
+        shift
+    elif echo "$1" | grep -q -s -E ^--pw-instance= ; then
+        pw_instance=$(echo "$1" | sed s/^--pw-instance=//)
+        shift
+    elif echo "$1" | grep -q -s -E ^--pw-credentials= ; then
+        pw_credential=$(echo "$1" | sed s/^--pw-credentials=//)
+        shift
+    elif echo "$1" | grep -E ^--help >/dev/null 2>&1; then
+        echo "patchwork monitor script"
+        echo "$0: args"
+        echo "Required if not set in ~/.pwmon-rc file:"
+        echo "  proj|--pw-project=<proj>		Project name"
+        echo "  instance|--pw-instance=<inst url>	URL for pw"
+        echo ""
+        echo "Options:"
+        echo "    --pw-credentials=u:p		Sets user / password for web client"
+        echo "    --add-filter-recheck=filter	Adds a filter to flag that a recheck needs to be done"
+        echo ""
+        exit 0
+    else
+        echo "Unknown option: '$1'"
+        echo "Rerun with --help for details"
+        exit 1
+    fi
+done
+
 if [ "X$pw_credential" != "X" ]; then
    userpw="-u \"${pw_credential}\""
 fi
 
+if [ "X$pw_instance" == "X" -o "X$pw_project" == "X" ]; then
+   echo "ERROR: Patchwork instance and project are unset."
+   echo "Please setup ${HOME}/.pwmon-rc and set pw_project "
+   echo "(or pass it as an argument)."
+   echo "Also either setup pw_instance or pass it as an argument."
+   exit 1
+fi
+
 source $(dirname $0)/series_db_lib.sh
 
 function emit_series() {
-- 
2.41.0