From e62506571fdb2ba9e095bb34653640e01e58f9c6 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Sat, 27 Oct 2018 22:52:29 -0700 Subject: env: `spack env destroy` is now `spack env remove` --- lib/spack/spack/cmd/env.py | 25 ++++++++++++++----------- lib/spack/spack/test/cmd/env.py | 18 +++++++++--------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/lib/spack/spack/cmd/env.py b/lib/spack/spack/cmd/env.py index 14deacd14e..b1b042de2e 100644 --- a/lib/spack/spack/cmd/env.py +++ b/lib/spack/spack/cmd/env.py @@ -30,7 +30,7 @@ subcommands = [ 'activate', 'deactivate', 'create', - 'destroy', + ['remove', 'rm'], ['list', 'ls'], ['status', 'st'], 'loads', @@ -210,33 +210,36 @@ def _env_create(name_or_path, init_file=None, dir=False): # # env remove # -def env_destroy_setup_parser(subparser): - """destroy an existing environment""" +def env_remove_setup_parser(subparser): + """remove an existing environment""" subparser.add_argument( - 'env', nargs='+', help='environment(s) to destroy') + 'env', nargs='+', help='environment(s) to remove') arguments.add_common_arguments(subparser, ['yes_to_all']) -def env_destroy(args): +def env_remove(args): + for env_name in args.env: + env = ev.disambiguate(env_name) + if not env: + tty.die('no such environment: %s' % env_name) + if not args.yes_to_all: answer = tty.get_yes_or_no( - 'Really destroy %s %s?' % ( + 'Really remove %s %s?' % ( string.plural(len(args.env), 'environment', show_n=False), string.comma_and(args.env)), default=False) if not answer: - tty.die("Will not destroy any environments") + tty.die("Will not remove any environments") for env_name in args.env: env = ev.disambiguate(env_name) - if not env: - tty.die('no such environment: %s' % env_name) if ev.active and ev.active.path == env.path: - tty.die("Environment %s can't be destroyed while activated.") + tty.die("Environment %s can't be removed while activated.") env.destroy() - tty.msg("Successfully destroyed environment '%s'" % env) + tty.msg("Successfully removed environment '%s'" % env) # diff --git a/lib/spack/spack/test/cmd/env.py b/lib/spack/spack/test/cmd/env.py index c3f01883b9..2712c4e59d 100644 --- a/lib/spack/spack/test/cmd/env.py +++ b/lib/spack/spack/test/cmd/env.py @@ -46,7 +46,7 @@ def test_env_list(): assert 'baz' in out -def test_env_destroy(capfd): +def test_env_remove(capfd): env('create', 'foo') env('create', 'bar') @@ -58,21 +58,21 @@ def test_env_destroy(capfd): with foo: with pytest.raises(spack.main.SpackCommandError): with capfd.disabled(): - env('destroy', '-y', 'foo') + env('remove', '-y', 'foo') assert 'foo' in env('list') - env('destroy', '-y', 'foo') + env('remove', '-y', 'foo') out = env('list') assert 'foo' not in out assert 'bar' in out - env('destroy', '-y', 'bar') + env('remove', '-y', 'bar') out = env('list') assert 'foo' not in out assert 'bar' not in out -def test_destroy_env_dir(capfd): +def test_remove_env_dir(capfd): env('create', '-d', 'foo') assert os.path.isdir('foo') @@ -80,9 +80,9 @@ def test_destroy_env_dir(capfd): with foo: with pytest.raises(spack.main.SpackCommandError): with capfd.disabled(): - env('destroy', '-y', 'foo') + env('remove', '-y', 'foo') - env('destroy', '-y', './foo') + env('remove', '-y', './foo') assert not os.path.isdir('foo') @@ -310,7 +310,7 @@ env: out = env('status', 'test') assert 'mpileaks' in out - env('destroy', '-y', 'test') + env('remove', '-y', 'test') out = env('list') assert 'test' not in out @@ -535,7 +535,7 @@ def test_env_commands_die_with_no_env_arg(): with pytest.raises(SystemExit): env('create') with pytest.raises(SystemExit): - env('destroy') + env('remove') # these have an optional env arg and raise errors via tty.die with pytest.raises(spack.main.SpackCommandError): -- cgit v1.2.3-60-g2f50