Make project mandatory config option
authorEd Bartosh <eduard.bartosh@intel.com>
Sat, 29 Mar 2014 22:31:52 +0000 (00:31 +0200)
committerEd Bartosh <eduard.bartosh@intel.com>
Tue, 1 Apr 2014 08:11:05 +0000 (11:11 +0300)
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 <eduard.bartosh@intel.com>
repa.1
repa/accept.py
repa/group.py
repa/info.py
repa/main.py
repa/reject.py
repa/rmgroup.py

diff --git a/repa.1 b/repa.1
index 2638e89b8d7f701d01c56ae1d08aab97ef5b8168..f16cb9b2842af46e91c3522c42f37f02a32b51ba 100644 (file)
--- 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 <eduard.bartosh@intel.com>.
 
index e76e84dc6a294ab03fdd97281a18689c073a8c0c..8292f24da9b4f38f80dc78159ba0f6ceccb829d1 100644 (file)
@@ -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
index 3b087b18c2d855359c165323dd8a21ace5048025..25be5aba7a6fc04a3e7a902e2acdbf2e7bcee770 100755 (executable)
@@ -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')
index baa4089a92bf5bfe9376c9414fdea405092d2ad7..7de8739a8e61dbd80a4b78a88ccbad896b2a70f0 100755 (executable)
@@ -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):
index d5cf03dd54bc6dd2f05fb3791b642e23c441fe8e..45177772daf1806d9b6246ddc36c13cec5c13ead 100755 (executable)
@@ -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.
index 4ee8d78333b766ae55f8bc11a9ceb1cff02b3e2e..a9077408638cb48ce81a83f359ae74b4beb24f2f 100644 (file)
@@ -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
index edbe73fcd7ebecf535241f7022aa9423e2d30e74..c3eac2a159faf9d16943a91d659f46b9396dcd4e 100644 (file)
@@ -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):