commit:     45afbf20372a5466f5704397944acb5f705402fc
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sun May 17 02:26:44 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Jun 19 19:51:17 2015 +0000
URL:        https://gitweb.gentoo.org/proj/webapp-config.git/commit/?id=45afbf20

config.py: Adds optionality to --dir flag

If the --dir flag is not specified with actions that require
the dir flag then webapp-config will default to the name of the
package as the installation directory.

 WebappConfig/config.py | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/WebappConfig/config.py b/WebappConfig/config.py
index 06dfc4c..c9c0baf 100644
--- a/WebappConfig/config.py
+++ b/WebappConfig/config.py
@@ -429,8 +429,9 @@ class Config:
                                '--dir',
                                nargs = 1,
                                help = 'Install <application> into DIR under 
the'
-                               ' htdocs dir. The default is '
-                               + self.config.get('USER', 'g_installdir'))
+                               ' htdocs dir. Not specifying using this flag'
+                               ' will result in defaulting to the package '
+                               ' name.')
 
         inst_locs.add_argument('-h',
                                '--host',
@@ -891,7 +892,6 @@ class Config:
 
         # Map command line options into the configuration
         option_to_config = {'host'         : 'vhost_hostname',
-                            'dir'          : 'g_installdir',
                             'server'       : 'vhost_server',
                             'secure'       : 'g_secure',
                             'user'         : 'vhost_config_uid',
@@ -1009,6 +1009,15 @@ class Config:
                         pvr += argsvr[i]
                 self.config.set('USER', 'pvr', pvr)
 
+            if not options['dir'] and self.work != 'list_installs':
+                pn  = self.config.get('USER', 'pn')
+                msg = 'Install dir flag not supplied, defaulting to '\
+                      '"%(pn)s".' % {'pn': pn}
+
+                OUT.warn(msg)
+                self.config.set('USER', 'g_installdir', pn)
+                self.flag_dir = True
+
 
     # --------------------------------------------------------------------
     # Helper functions

Reply via email to