1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 import os, sys, optparse
16
17 from conary.conaryclient import cmdline
18 from conary.lib import options, log
19 from conary import state, versions
20
21 (NO_PARAM, ONE_PARAM) = (options.NO_PARAM, options.ONE_PARAM)
22 (OPT_PARAM, MULT_PARAM) = (options.OPT_PARAM, options.MULT_PARAM)
23
25 docs = {'build-label' : (options.VERBOSE_HELP,
26 'Use build label LABEL as default search'
27 ' loc', 'LABEL'),
28 'components' : (options.VERBOSE_HELP,
29 'Do not hide components'),
30 'config' : (options.VERBOSE_HELP,
31 'Set config KEY to VALUE', '"KEY VALUE"'),
32 'config-file' : (options.VERBOSE_HELP,
33 'Read PATH config file', 'PATH'),
34 'context' : (options.VERBOSE_HELP,
35 'Set the current context'),
36 'exclude-troves' : (options.VERBOSE_HELP,
37 'Do not install troves matching REGEXP',
38 'REGEXP'),
39 'install-label' : (options.VERBOSE_HELP,
40 'Set the install label', 'LABEL'),
41 'interactive' : (options.VERBOSE_HELP,
42 'ask questions before performing actions '
43 'that change system or repository state'),
44 'flavors' : (options.VERBOSE_HELP,
45 'Display complete flavors where applicable'),
46 'full-versions' : (options.VERBOSE_HELP,
47 'Always display complete version strings'),
48 'labels' : (options.VERBOSE_HELP,
49 'Always display labels for versions'),
50 'profile' : optparse.SUPPRESS_HELP,
51 'lsprof' : optparse.SUPPRESS_HELP,
52 'pubring' : (options.VERBOSE_HELP, ''),
53 'skip-default-config': (options.VERBOSE_HELP,
54 "Don't read default configs"),
55 'quiet' : (options.VERBOSE_HELP,
56 'do not display extra information when '
57 'running'),
58 'root' : (options.VERBOSE_HELP,
59 'use conary database at location ROOT'),
60 'trust-threshold' : (options.VERBOSE_HELP,
61 'Set trust threshold', 'INT')
62 }
63
74
76 cfgMap['build-label'] = 'buildLabel', ONE_PARAM,
77 cfgMap['pubring'] = 'pubRing', ONE_PARAM
78 cfgMap['quiet'] = 'quiet', NO_PARAM,
79 cfgMap['root'] = 'root', ONE_PARAM, '-r'
80 cfgMap['flavors'] = 'fullFlavors', NO_PARAM
81 cfgMap['full-versions'] = 'fullVersions', NO_PARAM
82 cfgMap['interactive'] = 'interactive', NO_PARAM,
83 options.AbstractCommand.addConfigOptions(self, cfgMap, argDef)
84
85 - def setContext(self, cfg, argSet):
86 cmdline.setContext(cfg, argSet.pop('context', None),
87 searchCurrentDir=True)
88
106
108 commands = ['config']
109 help = 'Display the current configuration'
110 docs = {'show-contexts' : 'display contexts as well as current config',
111 'show-passwords' : 'do not mask passwords'}
112 commandGroup = 'Information Display'
113
119
120 - def runCommand(self, cfg, argSet, args, **kwargs):
121 showPasswords = argSet.pop('show-passwords', False)
122 showContexts = argSet.pop('show-contexts', False)
123 showLineOrigins = argSet.pop('show-files', False)
124 try:
125 prettyPrint = sys.stdout.isatty()
126 except AttributeError:
127 prettyPrint = False
128 cfg.setDisplayOptions(hidePasswords=not showPasswords,
129 showContexts=showContexts,
130 prettyPrint=prettyPrint,
131 showLineOrigins=showLineOrigins)
132 if argSet: return self.usage()
133 if (len(args) > 2):
134 return self.usage()
135 else:
136 cfg.display()
137
139 commands = ['help']
140 help = 'Display help information'
141 commandGroup = 'Information Display'
142
143 - def runCommand(self, cfg, argSet, args, **kwargs):
144 if len(args) == 3:
145 command = args[2]
146 commands = self.mainHandler._supportedCommands
147 if not command in commands:
148 print "%s: no such command: '%s'" % (self.mainHandler.name,
149 command)
150 sys.exit(1)
151 commands[command].usage()
152 elif len(args) == 2:
153 self.mainHandler.usage(showAll=True)
154 return 0
155 else:
156 print "%s: too many arguments: '%s'" % (self.mainHandler.name,
157 ' '.join(args[2:]))
158 sys.exit(1)
159
160 -class MainHandler(options.MainHandler):
162