diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2018-10-27 11:02:21 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2018-11-09 00:31:24 -0800 |
commit | 08e4720ed993783684435bef64063968c5ada362 (patch) | |
tree | 82b563adf449d70213d1761919fb8f42a12ed162 /lib | |
parent | d483e6e17bbca1c57853ffaee7e6547fd7a79aa6 (diff) | |
download | spack-08e4720ed993783684435bef64063968c5ada362.tar.gz spack-08e4720ed993783684435bef64063968c5ada362.tar.bz2 spack-08e4720ed993783684435bef64063968c5ada362.tar.xz spack-08e4720ed993783684435bef64063968c5ada362.zip |
env: remove all -e arguments on subcommands
- add and remove now require an active environment
- update tests to use with <ENV> instead of -e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/cmd/env.py | 21 | ||||
-rw-r--r-- | lib/spack/spack/test/cmd/env.py | 22 |
2 files changed, 25 insertions, 18 deletions
diff --git a/lib/spack/spack/cmd/env.py b/lib/spack/spack/cmd/env.py index 267cf91ea7..c0687a5603 100644 --- a/lib/spack/spack/cmd/env.py +++ b/lib/spack/spack/cmd/env.py @@ -61,13 +61,16 @@ def get_env(args, cmd_name, fail_on_error=True): """ env = args.env if not env: - env = os.environ.get('SPACK_ENV') - if not env: - if not fail_on_error: - return None - tty.die( - 'spack env %s requires an active environment or an argument' - % cmd_name) + if ev.active: + return ev.active + elif not fail_on_error: + return None + tty.die( + '`spack env %s` requires an environment' % cmd_name, + 'activate an environment first:', + ' spack env activate ENV', + 'or use:', + ' spack -e ENV %s ...' % cmd_name) environment = ev.disambiguate(env) @@ -309,8 +312,6 @@ def env_list(args): def env_add_setup_parser(subparser): """add a spec to an environment""" subparser.add_argument( - '-e', '--env', help='add spec to this environment') - subparser.add_argument( 'specs', nargs=argparse.REMAINDER, help="spec of the package to add") @@ -332,8 +333,6 @@ def env_add(args): def env_remove_setup_parser(subparser): """remove a spec from an environment""" subparser.add_argument( - '-e', '--env', help='remove spec with this name from environment') - subparser.add_argument( '-a', '--all', action='store_true', dest='all', help="Remove all specs from (clear) the environment") subparser.add_argument( diff --git a/lib/spack/spack/test/cmd/env.py b/lib/spack/spack/test/cmd/env.py index 0575f2d998..1dc6695353 100644 --- a/lib/spack/spack/test/cmd/env.py +++ b/lib/spack/spack/test/cmd/env.py @@ -144,18 +144,23 @@ def test_remove_after_concretize(): def test_remove_command(): env('create', 'test') - env('add', '-e', 'test', 'mpileaks') + with ev.read('test'): + env('add', 'mpileaks') assert 'mpileaks' in env('status', 'test') - env('remove', '-e', 'test', 'mpileaks') + with ev.read('test'): + env('remove', 'mpileaks') assert 'mpileaks' not in env('status', 'test') - env('add', '-e', 'test', 'mpileaks') + with ev.read('test'): + env('add', 'mpileaks') assert 'mpileaks' in env('status', 'test') + env('concretize', 'test') assert 'mpileaks' in env('status', 'test') - env('remove', '-e', 'test', 'mpileaks') + with ev.read('test'): + env('remove', 'mpileaks') assert 'mpileaks' not in env('status', 'test') @@ -478,7 +483,9 @@ env: def test_env_loads(install_mockery, mock_fetch): env('create', 'test') - env('add', '-e', 'test', 'mpileaks') + + with ev.read('test'): + env('add', 'mpileaks') env('concretize', 'test') env('install', '--fake', 'test') env('loads', 'test') @@ -496,8 +503,9 @@ def test_env_loads(install_mockery, mock_fetch): @pytest.mark.disable_clean_stage_check def test_env_stage(mock_stage, mock_fetch, install_mockery): env('create', 'test') - env('add', '-e', 'test', 'mpileaks') - env('add', '-e', 'test', 'zmpi') + with ev.read('test'): + print env('add', 'mpileaks') + print env('add', 'zmpi') env('concretize', 'test') env('stage', 'test') |