[PATCH v2 2/4] pwclient: require one or more of pwclient -{a,s}

Brian Norris computersforpeace at gmail.com
Sat Oct 17 10:39:01 AEDT 2015


Previously, we required the -s flag for 'pwclient update'. But since we
allow updating up to 2 different fields ('archived' and 'state'), drop
the required flag, and just enforce that the user must provide -a, -s,
or both.

Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
v2:
 * use ArgumentParser.error()
 * use 'is None' instead of '== None'

 patchwork/bin/pwclient | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/patchwork/bin/pwclient b/patchwork/bin/pwclient
index 236b237ddeb3..2193fd55034c 100755
--- a/patchwork/bin/pwclient
+++ b/patchwork/bin/pwclient
@@ -507,7 +507,6 @@ def main():
     )
     update_parser.add_argument(
         '-s', metavar='STATE',
-        required=True,
         help='''Set patch state (e.g., 'Accepted', 'Superseded' etc.)'''
     )
     update_parser.add_argument(
@@ -572,6 +571,9 @@ def main():
             sys.exit(1)
         commit_str = args.get('c')
 
+    if state_str is None and archived_str is None and action == 'update':
+        update_parser.error('Must specify one or more update options (-a or -s)')
+
     if args.get('n') != None:
         try:
             filt.add("max_count", args.get('n'))
-- 
2.6.0.rc2.230.g3dd15c0



More information about the Patchwork mailing list