100 parser = ArgumentParser(description="List information from the defects "
101 "database")
102 a = parser.add_argument
103 add_group = parser.add_argument_group
104
105 a(
"-c",
"--connection-string", default=DEFAULT_CONNECTION_STRING,
106 help="Database connection to use (default: %s)" % DEFAULT_CONNECTION_STRING)
107
108
109
110
111 tag_group = add_group("tags", "Show information about tags")
112 a = tag_group.add_argument
113
114 a(
"--tags", action=
"store_true",
115 help="List all available hierarchical tags")
116
117 a(
"--logic-tags", action=
"store_true",
118 help="Show all logic tags")
119
120 a(
"--defect-tags", action=
"store_true",
121 help="Show all defect tags")
122
123
124
125
126 defect_group = add_group("defects", "Show information about defects")
127 a = defect_group.add_argument
128
129 a(
"-t",
"--tag", default=
None,
130 help="Tag to use (default: HEAD)")
131
132 a(
"-l",
"--logic", action=
"store_true",
133 help="Show logic used for virtual flags (use -v)")
134
135 a(
"-V",
"--show-virtuality", action=
"store_true",
136 help="Indicate virtual vs nonvirtual flags")
137
138 a(
"-v",
"--virtual", action=
"store_true",
139 help="Show only virtual flags")
140
141 a(
"-p",
"--primary", action=
"store_true",
142 help="Show only primary flags")
143
144 a(
"-d",
"--descriptions", action=
"store_true",
145 help="Show descriptions")
146
147 a(
"patterns", metavar=
"defect", type=str, nargs=
"*", default=[],
148 help="One or more defect globs")
149
150
151 DEFECT_OPTIONS = ["logic", "show_virtuality", "virtual", "primary",
152 "descriptions", "patterns", "tag"]
153
154 args = parser.parse_args()
155
156
157
158 if args.tags or args.logic_tags or args.defect_tags:
159
160 for arg in DEFECT_OPTIONS:
161 if getattr(args, arg):
162 raise RuntimeError("--%s doesn't work with any --tags options" % arg)
163
164 show_tags(args.connection_string, args)
165
166 else:
167 if not args.patterns:
168
169 args.patterns = ["*"]
170 if not args.tag:
171 args.tag = "HEAD"
172
173 if args.logic:
174 assert not args.primary, "--primary doesn't work with --logic"
175 assert not args.descriptions, "--descriptions doesn't work with --logic"
176 assert not args.show_virtuality, "--show-virtuality doesn't work with --logic"
177
178 arguments = args.connection_string, args.tag, args.patterns, args
179
180 show_defects_with_logic(*arguments)
181 return
182
183 get_defects = get_both
184 if args.primary or args.virtual:
185 if args.primary and not args.virtual:
186 get_defects = get_primary
187 else:
188 get_defects = get_virtual
189
190 arguments = args.connection_string, args.tag, get_defects, args.patterns, args
191
192 if args.descriptions:
193 show_defects_with_desc(*arguments)
194 else:
195 show_defects(*arguments)
196