From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id B312D138202 for ; Thu, 12 Sep 2013 16:36:45 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1C9C9E0D53; Thu, 12 Sep 2013 16:36:43 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 92649E0D53 for ; Thu, 12 Sep 2013 16:36:42 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id A29C433EC3B for ; Thu, 12 Sep 2013 16:36:41 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 8B0F9E5464 for ; Thu, 12 Sep 2013 16:36:39 +0000 (UTC) From: "André Erdmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "André Erdmann" Message-ID: <1379003307.054be945040e7418fa0c100002b7d1bf81b0a25a.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/ X-VCS-Repository: proj/R_overlay X-VCS-Files: roverlay/argparser.py X-VCS-Directories: roverlay/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: 054be945040e7418fa0c100002b7d1bf81b0a25a X-VCS-Branch: master Date: Thu, 12 Sep 2013 16:36:39 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: c5671f87-f596-44f3-bab8-d29534d6aece X-Archives-Hash: a8c9359c8b5958b42f49497f0252bf1c commit: 054be945040e7418fa0c100002b7d1bf81b0a25a Author: André Erdmann mailerd de> AuthorDate: Thu Sep 12 16:28:27 2013 +0000 Commit: André Erdmann mailerd de> CommitDate: Thu Sep 12 16:28:27 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=054be945 roverlay/argparser: --usage action --- roverlay/argparser.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/roverlay/argparser.py b/roverlay/argparser.py index 1304874..561951e 100644 --- a/roverlay/argparser.py +++ b/roverlay/argparser.py @@ -23,6 +23,17 @@ from roverlay.argutil import \ ArgumentParserProxy + +class UsageAction ( argparse.Action ): + + def __call__ ( self, parser, namespace, values, option_string=None ): + parser.print_usage() + parser.exit() + # --- end of __call__ (...) --- + +# --- end of UsageAction --- + + class RoverlayArgumentParserBase ( roverlay.argutil.ArgumentParserProxy ): DESCRIPTION_TEMPLATE = None @@ -192,8 +203,16 @@ class RoverlayArgumentParserBase ( roverlay.argutil.ArgumentParserProxy ): '-V', '--version', action='version', version=self.defaults.get ( "version", roverlay.core.version ) ) + return self # --- end of setup_version (...) --- + def setup_usage ( self ): + self.arg ( + '--usage', action=UsageAction, help="print usage", nargs=0, + ) + return self + # --- end of setup_usage (...) --- + def setup_config_minimal ( self ): config_arg = self.add_argument_group ( 'config', title='config file options'