From 1f1a7c0a0a65667f906d32335b4a0e684a871c86 Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Sun, 30 Mar 2014 00:31:52 +0200 Subject: Make project mandatory config option As --project option was mandatory in most of the subcommands let's make project mandatory config option. --project becomes non-mandatory global option. Fixes: #1763 Change-Id: Id7f94fc5d60a1d163bde614ecf0605f944448337 Signed-off-by: Ed Bartosh --- repa.1 | 38 +++++++------------------------------- repa/accept.py | 2 -- repa/group.py | 2 -- repa/info.py | 2 -- repa/main.py | 6 ++++-- repa/reject.py | 2 -- repa/rmgroup.py | 2 -- 7 files changed, 11 insertions(+), 43 deletions(-) diff --git a/repa.1 b/repa.1 index 2638e89..f16cb9b 100644 --- a/repa.1 +++ b/repa.1 @@ -61,6 +61,13 @@ Print \fIrepa\fR version and exit. Print short help text and exit. .RE +.PP +.B \-p, \-\-project PROJECT +.RS 2 +Target OBS project. +.RE + + .\" =========================================================================== .\" Commands descriptions .\" =========================================================================== @@ -170,13 +177,6 @@ Package build failures: Print short help text about the "info" command and exit. .RE -.PP -\-p, \-\-project PROJECT -.RS 2 -Target project name. Mandatory option. -.RE - - .\" .\" The "accept" command description .\" @@ -197,12 +197,6 @@ Submit Requests in OBS for every submission and immediately accepting them. Print short help text about the "accept" command and exit. .RE -.PP -\-p, \-\-project PROJECT -.RS 2 -Target project name. Mandatory option. -.RE - .PP \-comment COMMENT .RS 2 @@ -229,12 +223,6 @@ Submit Requests in OBS for every submission and immediately rejecting them. Print short help text about the "reject" command and exit. .RE -.PP -\-p, \-\-project PROJECT -.RS 2 -Target project name. Mandatory option. -.RE - .PP \-comment COMMENT .RS 2 @@ -266,12 +254,6 @@ aggregates binaries only and is intended only for image testing. Print short help text about the "group" command and exit. .RE -.PP -\-p, \-\-project PROJECT -.RS 2 -Target project name. Mandatory option. -.RE - .PP \-comment COMMENT .RS 2 @@ -303,12 +285,6 @@ Remove submit group. Print short help text about the "rmgroup" command and exit. .RE -.PP -\-p, \-\-project PROJECT -.RS 2 -Target project name. Mandatory option. -.RE - .SH BUGS Please, report bugs to Ed Bartosh . diff --git a/repa/accept.py b/repa/accept.py index e76e84d..8292f24 100644 --- a/repa/accept.py +++ b/repa/accept.py @@ -47,8 +47,6 @@ class Accept(object): def add_arguments(parser, _config): """Adds arguments to the parser. Called from [sub_]main.""" parser.add_argument('submission', help='submission or group') - parser.add_argument('-p', '--project', help='target project', - required=True) parser.add_argument('-c', '--comment', help='comment', default='') @staticmethod diff --git a/repa/group.py b/repa/group.py index 3b087b1..25be5ab 100755 --- a/repa/group.py +++ b/repa/group.py @@ -164,8 +164,6 @@ class Group(object): """Adds arguments to the parser. Called from [sub_]main.""" parser.add_argument('submission', nargs='+', help='space separated list of submissions') - parser.add_argument('-p', '--project', help='target project', - required=True) parser.add_argument('-c', '--comment', help='comment', default='') parser.add_argument('-f', '--force', action='store_true', help='force group creation') diff --git a/repa/info.py b/repa/info.py index baa4089..7de8739 100755 --- a/repa/info.py +++ b/repa/info.py @@ -143,8 +143,6 @@ class Info(object): Set defaults for arguments from config. """ parser.add_argument('submission', help='submission or group') - parser.add_argument('-p', '--project', help='target project', - required=True) @staticmethod def run(argv): diff --git a/repa/main.py b/repa/main.py index d5cf03d..4517777 100755 --- a/repa/main.py +++ b/repa/main.py @@ -59,7 +59,9 @@ def parse_args(argv): version='%(prog)s version 0.2~0.dev') parser.add_argument('-s', '--section', default='general', help='config section to use') - # Define subcommands using setup.py entry points + parser.add_argument('-p', '--project', help='target project', + default=config.get('project')) + subparsers = parser.add_subparsers(help='sub-command help') for entry in pkg_resources.iter_entry_points(group='repa_commands'): cmd = entry.load()() @@ -77,7 +79,7 @@ def parse_args(argv): def read_config(paths=('/etc/repa.conf', expanduser('~/.repa.conf')), section='general', - mandatory=('apiurl', 'apiuser', 'apipasswd')): + mandatory=('apiurl', 'apiuser', 'apipasswd', 'project')): """ Read repa config. Configuration is read from the set of files provided. diff --git a/repa/reject.py b/repa/reject.py index 4ee8d78..a907740 100644 --- a/repa/reject.py +++ b/repa/reject.py @@ -47,8 +47,6 @@ class Reject(object): def add_arguments(parser, _config): """Adds arguments to the parser. Called from [sub_]main.""" parser.add_argument('submission', help='submission or group') - parser.add_argument('-p', '--project', help='target project', - required=True) parser.add_argument('-c', '--comment', help='comment', default='') @staticmethod diff --git a/repa/rmgroup.py b/repa/rmgroup.py index edbe73f..c3eac2a 100644 --- a/repa/rmgroup.py +++ b/repa/rmgroup.py @@ -56,8 +56,6 @@ class RmGroup(object): def add_arguments(parser, _config): """Adds arguments to the parser. Called from [sub_]main.""" parser.add_argument('group', help='group of submissions') - parser.add_argument('-p', '--project', help='target project', - required=True) @staticmethod def run(argv): -- cgit v1.2.3