spack buildcache check: use same interface as push (#41378)

This commit is contained in:
Harmen Stoppels 2023-12-05 12:44:50 +01:00 committed by GitHub
parent 3547bcb517
commit 3cefd73fcc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 9 deletions

View file

@ -188,14 +188,16 @@ def setup_parser(subparser: argparse.ArgumentParser):
default=lambda: spack.config.default_modify_scope(), default=lambda: spack.config.default_modify_scope(),
help="configuration scope containing mirrors to check", help="configuration scope containing mirrors to check",
) )
check_spec_or_specfile = check.add_mutually_exclusive_group(required=True) # Unfortunately there are 3 ways to do the same thing here:
check_spec_or_specfile.add_argument( check_specs = check.add_mutually_exclusive_group()
check_specs.add_argument(
"-s", "--spec", help="check single spec instead of release specs file" "-s", "--spec", help="check single spec instead of release specs file"
) )
check_spec_or_specfile.add_argument( check_specs.add_argument(
"--spec-file", "--spec-file",
help="check single spec from json or yaml file instead of release specs file", help="check single spec from json or yaml file instead of release specs file",
) )
arguments.add_common_arguments(check, ["specs"])
check.set_defaults(func=check_fn) check.set_defaults(func=check_fn)
@ -813,15 +815,24 @@ def check_fn(args: argparse.Namespace):
exit code is non-zero, then at least one of the indicated specs needs to be rebuilt exit code is non-zero, then at least one of the indicated specs needs to be rebuilt
""" """
if args.spec_file: if args.spec_file:
specs_arg = (
args.spec_file if os.path.sep in args.spec_file else os.path.join(".", args.spec_file)
)
tty.warn( tty.warn(
"The flag `--spec-file` is deprecated and will be removed in Spack 0.22. " "The flag `--spec-file` is deprecated and will be removed in Spack 0.22. "
"Use --spec instead." f"Use `spack buildcache check {specs_arg}` instead."
) )
elif args.spec:
specs_arg = args.spec
tty.warn(
"The flag `--spec` is deprecated and will be removed in Spack 0.23. "
f"Use `spack buildcache check {specs_arg}` instead."
)
else:
specs_arg = args.specs
specs = spack.cmd.parse_specs(args.spec or args.spec_file) if specs_arg:
specs = _matching_specs(spack.cmd.parse_specs(specs_arg))
if specs:
specs = _matching_specs(specs)
else: else:
specs = spack.cmd.require_active_env("buildcache check").all_specs() specs = spack.cmd.require_active_env("buildcache check").all_specs()

View file

@ -618,7 +618,12 @@ _spack_buildcache_preview() {
} }
_spack_buildcache_check() { _spack_buildcache_check() {
SPACK_COMPREPLY="-h --help -m --mirror-url -o --output-file --scope -s --spec --spec-file" if $list_options
then
SPACK_COMPREPLY="-h --help -m --mirror-url -o --output-file --scope -s --spec --spec-file"
else
_all_packages
fi
} }
_spack_buildcache_download() { _spack_buildcache_download() {

View file

@ -797,6 +797,7 @@ complete -c spack -n '__fish_spack_using_command buildcache preview' -s h -l hel
# spack buildcache check # spack buildcache check
set -g __fish_spack_optspecs_spack_buildcache_check h/help m/mirror-url= o/output-file= scope= s/spec= spec-file= set -g __fish_spack_optspecs_spack_buildcache_check h/help m/mirror-url= o/output-file= scope= s/spec= spec-file=
complete -c spack -n '__fish_spack_using_command_pos_remainder 0 buildcache check' -f -k -a '(__fish_spack_specs)'
complete -c spack -n '__fish_spack_using_command buildcache check' -s h -l help -f -a help complete -c spack -n '__fish_spack_using_command buildcache check' -s h -l help -f -a help
complete -c spack -n '__fish_spack_using_command buildcache check' -s h -l help -d 'show this help message and exit' complete -c spack -n '__fish_spack_using_command buildcache check' -s h -l help -d 'show this help message and exit'
complete -c spack -n '__fish_spack_using_command buildcache check' -s m -l mirror-url -r -f -a mirror_url complete -c spack -n '__fish_spack_using_command buildcache check' -s m -l mirror-url -r -f -a mirror_url