summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2013-02-22 00:20:24 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2013-02-22 00:20:24 -0800
commit27b92047854d47465b7efeef8f1bc6f8922ba91c (patch)
tree758ccb8ebe07c0fa39a45655dd8c99cf77184452 /lib
parent707db8dafe7080888577e78f1d4df02b8779a491 (diff)
downloadspack-27b92047854d47465b7efeef8f1bc6f8922ba91c.tar.gz
spack-27b92047854d47465b7efeef8f1bc6f8922ba91c.tar.bz2
spack-27b92047854d47465b7efeef8f1bc6f8922ba91c.tar.xz
spack-27b92047854d47465b7efeef8f1bc6f8922ba91c.zip
Better spack -h: added cmd descriptions.
- each cmd has a desscription attribute that is used for the help strign in argparse.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/__init__.py13
-rw-r--r--lib/spack/spack/cmd/clean.py2
-rw-r--r--lib/spack/spack/cmd/create.py2
-rw-r--r--lib/spack/spack/cmd/edit.py1
-rw-r--r--lib/spack/spack/cmd/fetch.py2
-rw-r--r--lib/spack/spack/cmd/graph.py1
-rw-r--r--lib/spack/spack/cmd/help.py2
-rw-r--r--lib/spack/spack/cmd/install.py2
-rw-r--r--lib/spack/spack/cmd/list.py1
-rw-r--r--lib/spack/spack/cmd/purge.py2
-rw-r--r--lib/spack/spack/cmd/stage.py2
-rw-r--r--lib/spack/spack/cmd/uninstall.py2
12 files changed, 29 insertions, 3 deletions
diff --git a/lib/spack/spack/cmd/__init__.py b/lib/spack/spack/cmd/__init__.py
index 8d2f263b63..a54ade741e 100644
--- a/lib/spack/spack/cmd/__init__.py
+++ b/lib/spack/spack/cmd/__init__.py
@@ -3,11 +3,14 @@ import re
import spack
import spack.tty as tty
+import spack.attr as attr
# Patterns to ignore in the commands directory when looking for commands.
ignore_files = r'^\.|^__init__.py$|^#'
-setup_parser = "setup_parser"
+SETUP_PARSER = "setup_parser"
+DESCRIPTION = "description"
+
command_path = os.path.join(spack.lib_path, "spack", "cmd")
commands = []
@@ -25,8 +28,12 @@ def null_op(*args):
def get_module(name):
"""Imports the module for a particular command name and returns it."""
module_name = "%s.%s" % (__name__, name)
- module = __import__(module_name, fromlist=[name, setup_parser], level=0)
- module.setup_parser = getattr(module, setup_parser, null_op)
+ module = __import__(
+ module_name, fromlist=[name, SETUP_PARSER, DESCRIPTION],
+ level=0)
+
+ attr.setdefault(module, SETUP_PARSER, null_op)
+ attr.setdefault(module, DESCRIPTION, "")
if not hasattr(module, name):
tty.die("Command module %s (%s) must define function '%s'."
diff --git a/lib/spack/spack/cmd/clean.py b/lib/spack/spack/cmd/clean.py
index 09922887ca..33f1d68a46 100644
--- a/lib/spack/spack/cmd/clean.py
+++ b/lib/spack/spack/cmd/clean.py
@@ -2,6 +2,8 @@ import spack.packages as packages
import spack.tty as tty
import spack.stage as stage
+description = "Remove staged files for packages"
+
def setup_parser(subparser):
subparser.add_argument('names', nargs='+', help="name(s) of package(s) to clean")
subparser.add_argument('-c', "--clean", action="store_true", dest='clean',
diff --git a/lib/spack/spack/cmd/create.py b/lib/spack/spack/cmd/create.py
index 0997c4a53f..36b6d0e571 100644
--- a/lib/spack/spack/cmd/create.py
+++ b/lib/spack/spack/cmd/create.py
@@ -9,6 +9,8 @@ import spack.version
from spack.stage import Stage
from contextlib import closing
+description = "Create a new package file from an archive URL"
+
package_template = string.Template("""\
from spack import *
diff --git a/lib/spack/spack/cmd/edit.py b/lib/spack/spack/cmd/edit.py
index aa279ca295..e9e781ecd6 100644
--- a/lib/spack/spack/cmd/edit.py
+++ b/lib/spack/spack/cmd/edit.py
@@ -3,6 +3,7 @@ import spack
import spack.packages as packages
import spack.tty as tty
+description = "Open package files in $EDITOR"
def setup_parser(subparser):
subparser.add_argument(
diff --git a/lib/spack/spack/cmd/fetch.py b/lib/spack/spack/cmd/fetch.py
index c53fce6f6f..c447435862 100644
--- a/lib/spack/spack/cmd/fetch.py
+++ b/lib/spack/spack/cmd/fetch.py
@@ -1,5 +1,7 @@
import spack.packages as packages
+description = "Fetch archives for packages"
+
def setup_parser(subparser):
subparser.add_argument('name', help="name of package to fetch")
subparser.add_argument('-f', '--file', dest='file', default=None,
diff --git a/lib/spack/spack/cmd/graph.py b/lib/spack/spack/cmd/graph.py
index 3c16a825a7..2cf08870d2 100644
--- a/lib/spack/spack/cmd/graph.py
+++ b/lib/spack/spack/cmd/graph.py
@@ -1,6 +1,7 @@
import spack
import spack.packages as packages
+description = "Write out inter-package dependencies in dot graph format"
def graph(parser, args):
packages.graph_dependencies()
diff --git a/lib/spack/spack/cmd/help.py b/lib/spack/spack/cmd/help.py
index a2b61a2bc9..c90fc50ace 100644
--- a/lib/spack/spack/cmd/help.py
+++ b/lib/spack/spack/cmd/help.py
@@ -1,5 +1,7 @@
import sys
+description = "Get help on spack and its commands"
+
def setup_parser(subparser):
subparser.add_argument('help_command', nargs='?', default=None,
help='command to get help on')
diff --git a/lib/spack/spack/cmd/install.py b/lib/spack/spack/cmd/install.py
index 14bae90147..9494838832 100644
--- a/lib/spack/spack/cmd/install.py
+++ b/lib/spack/spack/cmd/install.py
@@ -1,6 +1,8 @@
import spack
import spack.packages as packages
+description = "Build and install packages"
+
def setup_parser(subparser):
subparser.add_argument('names', nargs='+', help="name(s) of package(s) to install")
subparser.add_argument('-i', '--ignore-dependencies',
diff --git a/lib/spack/spack/cmd/list.py b/lib/spack/spack/cmd/list.py
index 2746946ddf..f4f36220c6 100644
--- a/lib/spack/spack/cmd/list.py
+++ b/lib/spack/spack/cmd/list.py
@@ -2,6 +2,7 @@ import spack
import spack.packages as packages
from spack.colify import colify
+description ="List spack packages"
def setup_parser(subparser):
subparser.add_argument('-i', '--installed', action='store_true', dest='installed',
diff --git a/lib/spack/spack/cmd/purge.py b/lib/spack/spack/cmd/purge.py
index 99f1b98c23..3fc5e583d4 100644
--- a/lib/spack/spack/cmd/purge.py
+++ b/lib/spack/spack/cmd/purge.py
@@ -1,4 +1,6 @@
import spack.stage as stage
+description = "Remove all temporary build files and downloaded archives"
+
def purge(parser, args):
stage.purge()
diff --git a/lib/spack/spack/cmd/stage.py b/lib/spack/spack/cmd/stage.py
index 0d7ba23d4b..ad12955b41 100644
--- a/lib/spack/spack/cmd/stage.py
+++ b/lib/spack/spack/cmd/stage.py
@@ -1,5 +1,7 @@
import spack.packages as packages
+description="Expand downloaded archive in preparation for install"
+
def setup_parser(subparser):
subparser.add_argument('name', help="name of package to stage")
diff --git a/lib/spack/spack/cmd/uninstall.py b/lib/spack/spack/cmd/uninstall.py
index 96b3c45bc5..2cc5aeb2c8 100644
--- a/lib/spack/spack/cmd/uninstall.py
+++ b/lib/spack/spack/cmd/uninstall.py
@@ -1,5 +1,7 @@
import spack.packages as packages
+description="Remove an installed package"
+
def setup_parser(subparser):
subparser.add_argument('names', nargs='+', help="name(s) of package(s) to uninstall")
subparser.add_argument('-f', '--force', action='store_true', dest='force',