Skip to content

Commit c0894ab

Browse files
committed
feat: add pinspect eapi {list,phases}
The point of this is to be able to do some basic commandline introspection of supported EAPIs; in particular, so you can see what phases are valid in a given EAPI. Signed-off-by: Brian Harring <ferringb@gmail.com>
1 parent dc31ba2 commit c0894ab

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

src/pkgcore/scripts/pinspect.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from snakeoil.sequences import iflatten_instance, unstable_unique
2424

2525
from .. import fetch
26-
from ..ebuild import inspect_profile
26+
from ..ebuild import inspect_profile, eapi
2727
from ..ebuild import portageq as _portageq
2828
from ..package import errors
2929
from ..restrictions import packages
@@ -234,6 +234,37 @@ def __call__(self, opts, out, err):
234234
return 0
235235

236236

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+
237268
class eapi_usage_kls(histo_data):
238269
per_repo_format = "eapi: %(key)r %(val)s pkgs found, %(percent)s of the repo"
239270

0 commit comments

Comments
 (0)