diff options
author | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2024-01-18 10:11:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-18 10:11:41 +0100 |
commit | 203d682d879055fbe781135f01d2ae793ecc0207 (patch) | |
tree | 51ba37d02f547d4987a09d382591838b815a8f10 | |
parent | 7b27591321fca14c519e75a3ab76a7e231347594 (diff) | |
download | spack-203d682d879055fbe781135f01d2ae793ecc0207.tar.gz spack-203d682d879055fbe781135f01d2ae793ecc0207.tar.bz2 spack-203d682d879055fbe781135f01d2ae793ecc0207.tar.xz spack-203d682d879055fbe781135f01d2ae793ecc0207.zip |
spack graph: env aware (#42093)
-rw-r--r-- | lib/spack/spack/cmd/graph.py | 36 | ||||
-rwxr-xr-x | share/spack/spack-completion.fish | 2 |
2 files changed, 23 insertions, 15 deletions
diff --git a/lib/spack/spack/cmd/graph.py b/lib/spack/spack/cmd/graph.py index f76e9dbeac..36a49a1ea0 100644 --- a/lib/spack/spack/cmd/graph.py +++ b/lib/spack/spack/cmd/graph.py @@ -18,7 +18,14 @@ level = "long" def setup_parser(subparser): setup_parser.parser = subparser + subparser.epilog = """ +Outside of an environment, the command concretizes specs and graphs them, unless the +--installed option is given. In that case specs are matched from the current DB. +If an environment is active, specs are matched from the currently available concrete specs +in the lockfile. + +""" method = subparser.add_mutually_exclusive_group() method.add_argument( "-a", "--ascii", action="store_true", help="draw graph as ascii to stdout (default)" @@ -41,39 +48,40 @@ def setup_parser(subparser): ) subparser.add_argument( - "-i", - "--installed", - action="store_true", - help="graph installed specs, or specs in the active env (implies --dot)", + "-i", "--installed", action="store_true", help="graph specs from the DB" ) arguments.add_common_arguments(subparser, ["deptype", "specs"]) def graph(parser, args): - if args.installed and args.specs: - tty.die("cannot specify specs with --installed") + env = ev.active_environment() + if args.installed and env: + tty.die("cannot use --installed with an active environment") if args.color and not args.dot: tty.die("the --color option can be used only with --dot") if args.installed: - args.dot = True - env = ev.active_environment() - if env: - specs = env.concrete_roots() - else: + if not args.specs: specs = spack.store.STORE.db.query() + else: + result = [] + for item in args.specs: + result.extend(spack.store.STORE.db.query(item)) + specs = list(set(result)) + elif env: + specs = env.concrete_roots() + if args.specs: + specs = env.all_matching_specs(*args.specs) else: specs = spack.cmd.parse_specs(args.specs, concretize=not args.static) if not specs: - setup_parser.parser.print_help() - return 1 + tty.die("no spec matching the query") if args.static: - args.dot = True static_graph_dot(specs, depflag=args.deptype) return diff --git a/share/spack/spack-completion.fish b/share/spack/spack-completion.fish index 10c92bc6f1..5a12414d76 100755 --- a/share/spack/spack-completion.fish +++ b/share/spack/spack-completion.fish @@ -1885,7 +1885,7 @@ complete -c spack -n '__fish_spack_using_command graph' -s s -l static -d 'graph complete -c spack -n '__fish_spack_using_command graph' -s c -l color -f -a color complete -c spack -n '__fish_spack_using_command graph' -s c -l color -d 'use different colors for different dependency types' complete -c spack -n '__fish_spack_using_command graph' -s i -l installed -f -a installed -complete -c spack -n '__fish_spack_using_command graph' -s i -l installed -d 'graph installed specs, or specs in the active env (implies --dot)' +complete -c spack -n '__fish_spack_using_command graph' -s i -l installed -d 'graph specs from the DB' complete -c spack -n '__fish_spack_using_command graph' -l deptype -r -f -a deptype complete -c spack -n '__fish_spack_using_command graph' -l deptype -r -d 'comma-separated list of deptypes to traverse (default=build,link,run,test)' |