Gentoo Archives: gentoo-commits

From: Brian Dolbec <brian.dolbec@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/layman:master commit in: layman/
Date: Mon, 29 Jul 2013 01:46:20
Message-Id: 1375062294.2ea5d6470df7eebe35b17b898eabb58df2fa8b5c.dol-sen@gentoo
1 commit: 2ea5d6470df7eebe35b17b898eabb58df2fa8b5c
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Mon Jul 29 01:40:32 2013 +0000
4 Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
5 CommitDate: Mon Jul 29 01:44:54 2013 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=2ea5d647
7
8 Add cli options to both layman-updater and layman to print the setup help messages.
9
10 ---
11 layman/argsparser.py | 8 ++++++++
12 layman/cli.py | 7 +++++++
13 layman/updater.py | 15 ++++++++++-----
14 3 files changed, 25 insertions(+), 5 deletions(-)
15
16 diff --git a/layman/argsparser.py b/layman/argsparser.py
17 index 3afc3ea..3e3d6f6 100644
18 --- a/layman/argsparser.py
19 +++ b/layman/argsparser.py
20 @@ -82,6 +82,12 @@ class ArgsParser(BareConfig):
21 usage = _USAGE,
22 version = VERSION)
23
24 + self.parser.add_option('-H',
25 + '--setup_help',
26 + action = 'store_true',
27 + help = 'Print the NEW INSTALL help messages.')
28 +
29 +
30 #-----------------------------------------------------------------
31 # Main Options
32
33 @@ -283,6 +289,8 @@ class ArgsParser(BareConfig):
34 self.output.debug('ARGSPARSER: Got overlay_defs location at ' + \
35 self.defaults['overlay_defs'], 8)
36
37 + self._options['setup_help'] = self.options.__dict__['setup_help']
38 +
39 # Now parse the config file
40 self.output.debug('ARGSPARSER: Reading config file at ' + \
41 self.defaults['config'], 8)
42
43 diff --git a/layman/cli.py b/layman/cli.py
44 index 25c6f9a..a5d2799 100644
45 --- a/layman/cli.py
46 +++ b/layman/cli.py
47 @@ -149,6 +149,13 @@ class Main(object):
48 " %s" % str(self.config.keys()), 6)
49 # blank newline -- no " *"
50 self.output.notice('')
51 +
52 + # check for and handle setup-help option
53 + if self.config.get_option('setup_help'):
54 + from layman.updater import Main as Updater
55 + updater = Updater(config=self.config, output=self.output)
56 + updater.print_instructions()
57 +
58 # Make fetching the overlay list a default action
59 if not 'nofetch' in self.config.keys():
60 # Actions that implicitely call the fetch operation before
61
62 diff --git a/layman/updater.py b/layman/updater.py
63 index b9b72bc..f7d91e6 100644
64 --- a/layman/updater.py
65 +++ b/layman/updater.py
66 @@ -36,20 +36,23 @@ def rename_db(config, newname, output):
67
68 class Main(object):
69
70 - def __init__(self, root=None):
71 + def __init__(self, root=None, config=None, output=None):
72 self.parser = None
73 - self.output = None
74 - self.config = None
75 + self.output = output
76 + self.config = config
77 self.args = None
78 self.root = root
79
80 def args_parser(self):
81 self.parser = argparse.ArgumentParser(prog='layman-updater',
82 description="Layman's update script")
83 + self.parser.add_argument("-H", '--setup_help', action='store_true',
84 + help = 'Print the NEW INSTALL help messages.')
85 self.parser.add_argument("-c", "--config",
86 help='the path to config file')
87 self.parser.add_argument('--version', action='version',
88 version='%(prog)s ' + VERSION)
89 +
90 self.args = self.parser.parse_args()
91
92 def __call__(self):
93 @@ -64,7 +67,7 @@ class Main(object):
94 # fix the config path
95 defaults = self.config.get_defaults()
96 defaults['config'] = defaults['config'] \
97 - % {'configdir': defaults['configdir']}
98 + % {'configdir': defaults['configdir']}
99 self.config.update_defaults({'config': defaults['config']})
100
101 self.config.read_config(defaults)
102 @@ -73,7 +76,9 @@ class Main(object):
103
104 self.output = layman_inst.output
105
106 - if not self.check_is_new():
107 + if self.args.setup_help:
108 + self.print_instructions()
109 + elif not self.check_is_new():
110 self.rename_check()