|
23 | 23 | from snakeoil.sequences import iflatten_instance, unstable_unique |
24 | 24 |
|
25 | 25 | from .. import fetch |
26 | | -from ..ebuild import inspect_profile |
| 26 | +from ..ebuild import inspect_profile, eapi |
27 | 27 | from ..ebuild import portageq as _portageq |
28 | 28 | from ..package import errors |
29 | 29 | from ..restrictions import packages |
@@ -234,6 +234,37 @@ def __call__(self, opts, out, err): |
234 | 234 | return 0 |
235 | 235 |
|
236 | 236 |
|
| 237 | +eapi_subparser = subparsers.add_parser("eapi", description="EAPI related functionality").add_subparsers() |
| 238 | + |
| 239 | +eapi_list = eapi_subparser.add_parser( |
| 240 | + "list", description="list all EAPIs pkgcore knows" |
| 241 | +) |
| 242 | + |
| 243 | +eapi_list.add_argument( |
| 244 | + "--pms", action="store_true", default=False, help="Filter to just PMS EAPIS" |
| 245 | +) |
| 246 | + |
| 247 | + |
| 248 | +@eapi_list.bind_main_func |
| 249 | +def eapi_list(opts, out, _err): |
| 250 | + out.write("\n".join( |
| 251 | + str(magic) for (magic, obj) in eapi.EAPI.known_eapis.items() if obj.pms or not opts.pms |
| 252 | + )) |
| 253 | + |
| 254 | + |
| 255 | +eapi_phases = eapi_subparser.add_parser( |
| 256 | + "phases", description="list the phases of a given EAPI" |
| 257 | +) |
| 258 | +eapi_phases.add_argument("eapi", metavar="EAPI", help="the EAPI to inspect") |
| 259 | + |
| 260 | + |
| 261 | +@eapi_phases.bind_main_func |
| 262 | +def eapi_phases(opts, out, err): |
| 263 | + if not (obj := eapi.EAPI.known_eapis.get(opts.eapi)): |
| 264 | + raise arghparse.argparse.ArgumentTypeError(f"eapi '{opts.eapi}' is unsupported") |
| 265 | + out.write("\n".join(sorted(obj.phases.values()))) |
| 266 | + |
| 267 | + |
237 | 268 | class eapi_usage_kls(histo_data): |
238 | 269 | per_repo_format = "eapi: %(key)r %(val)s pkgs found, %(percent)s of the repo" |
239 | 270 |
|
|
0 commit comments