diff mbox

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

Message ID 1445037127-45750-2-git-send-email-computersforpeace@gmail.com
State Superseded
Headers show

Commit Message

Brian Norris Oct. 16, 2015, 11:12 p.m. UTC
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@gmail.com>
---
 patchwork/bin/pwclient | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Mike Frysinger Oct. 16, 2015, 11:18 p.m. UTC | #1
On 16 Oct 2015 16:12, Brian Norris wrote:
> 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@gmail.com>
> ---
>  patchwork/bin/pwclient | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/patchwork/bin/pwclient b/patchwork/bin/pwclient
> index 236b237ddeb3..596a26d8aa9d 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,11 @@ def main():
>              sys.exit(1)
>          commit_str = args.get('c')
>  
> +    if state_str == None and archived_str == None and action == 'update':

use "is None" instead of "== None"

> +        sys.stderr.write("Must specify one or more update options (-a or -s)\n")
> +        update_parser.print_help()
> +        sys.exit(1)

better to use:
	update_parser.error('Must specify one or more update options (-a or -s)')

probably should convert all the other users that do this too
-mike
diff mbox

Patch

diff --git a/patchwork/bin/pwclient b/patchwork/bin/pwclient
index 236b237ddeb3..596a26d8aa9d 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,11 @@  def main():
             sys.exit(1)
         commit_str = args.get('c')
 
+    if state_str == None and archived_str == None and action == 'update':
+        sys.stderr.write("Must specify one or more update options (-a or -s)\n")
+        update_parser.print_help()
+        sys.exit(1)
+
     if args.get('n') != None:
         try:
             filt.add("max_count", args.get('n'))