summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2015-07-06 19:57:31 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2015-08-16 12:50:39 -0700
commitda98b07624e2403807166e8a9d0dac3752f75c0f (patch)
tree3a9206d957537d65b7c4255b1a30edccbb658369 /lib
parente58ee88a632a0855a984cba8f0faa725b8f2eddf (diff)
downloadspack-da98b07624e2403807166e8a9d0dac3752f75c0f.tar.gz
spack-da98b07624e2403807166e8a9d0dac3752f75c0f.tar.bz2
spack-da98b07624e2403807166e8a9d0dac3752f75c0f.tar.xz
spack-da98b07624e2403807166e8a9d0dac3752f75c0f.zip
Add more options to `spack edit`
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/edit.py35
1 files changed, 21 insertions, 14 deletions
diff --git a/lib/spack/spack/cmd/edit.py b/lib/spack/spack/cmd/edit.py
index b8764ba391..9081d12516 100644
--- a/lib/spack/spack/cmd/edit.py
+++ b/lib/spack/spack/cmd/edit.py
@@ -78,9 +78,18 @@ def setup_parser(subparser):
subparser.add_argument(
'-f', '--force', dest='force', action='store_true',
help="Open a new file in $EDITOR even if package doesn't exist.")
- subparser.add_argument(
- '-c', '--command', dest='edit_command', action='store_true',
- help="Edit the command with the supplied name instead of a package.")
+
+ filetypes = subparser.add_mutually_exclusive_group()
+ filetypes.add_argument(
+ '-c', '--command', dest='path', action='store_const',
+ const=spack.cmd.command_path, help="Edit the command with the supplied name.")
+ filetypes.add_argument(
+ '-t', '--test', dest='path', action='store_const',
+ const=spack.test_path, help="Edit the test with the supplied name.")
+ filetypes.add_argument(
+ '-m', '--module', dest='path', action='store_const',
+ const=spack.module_path, help="Edit the main spack module with the supplied name.")
+
subparser.add_argument(
'name', nargs='?', default=None, help="name of package to edit")
@@ -88,19 +97,17 @@ def setup_parser(subparser):
def edit(parser, args):
name = args.name
- if args.edit_command:
- if not name:
- path = spack.cmd.command_path
- else:
- path = join_path(spack.cmd.command_path, name + ".py")
- if not os.path.exists(path):
+ path = spack.packages_path
+ if args.path:
+ path = args.path
+ if name:
+ path = join_path(path, name + ".py")
+ if not args.force and not os.path.exists(path):
tty.die("No command named '%s'." % name)
spack.editor(path)
+ elif name:
+ edit_package(name, args.force)
else:
# By default open the directory where packages or commands live.
- if not name:
- path = spack.packages_path
- spack.editor(path)
- else:
- edit_package(name, args.force)
+ spack.editor(path)