We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
spack find does not accept same specs as other commands
The following works:
```
$ spack find hdf5~mpi
```
but the following equivalent command does not:
```
$ spack find hdf5 -mpi
usage: spack find [-h] [-s | -p | -d] [-l] [-L] [-f] [-e | -E] [-u] [-m] [-v]
                  [-M] [-N]
                  [constraint [constraint ...]]
spack find: error: argument -p/--paths: ignored explicit argument 'i'
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `lib/spack/spack/cmd/common/arguments.py`
Content:
```
1 ##############################################################################
2 # Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
3 # Produced at the Lawrence Livermore National Laboratory.
4 #
5 # This file is part of Spack.
6 # Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
7 # LLNL-CODE-647188
8 #
9 # For details, see https://github.com/llnl/spack
10 # Please also see the LICENSE file for our notice and the LGPL.
11 #
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU Lesser General Public License (as
14 # published by the Free Software Foundation) version 2.1, February 1999.
15 #
16 # This program is distributed in the hope that it will be useful, but
17 # WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
19 # conditions of the GNU Lesser General Public License for more details.
20 #
21 # You should have received a copy of the GNU Lesser General Public
22 # License along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 ##############################################################################
25 
26 import argparse
27 
28 import spack.cmd
29 import spack.store
30 import spack.modules
31 from spack.util.pattern import Args
32 __all__ = ['add_common_arguments']
33 
34 _arguments = {}
35 
36 
37 def add_common_arguments(parser, list_of_arguments):
38     for argument in list_of_arguments:
39         if argument not in _arguments:
40             message = 'Trying to add non existing argument "{0}" to a command'
41             raise KeyError(message.format(argument))
42         x = _arguments[argument]
43         parser.add_argument(*x.flags, **x.kwargs)
44 
45 
46 class ConstraintAction(argparse.Action):
47     """Constructs a list of specs based on a constraint given on the command line
48 
49     An instance of this class is supposed to be used as an argument action
50     in a parser. It will read a constraint and will attach a function to the
51     arguments that accepts optional keyword arguments.
52 
53     To obtain the specs from a command the function must be called.
54     """
55 
56     def __call__(self, parser, namespace, values, option_string=None):
57         # Query specs from command line
58         self.values = values
59         namespace.constraint = values
60         namespace.specs = self._specs
61 
62     def _specs(self, **kwargs):
63         qspecs = spack.cmd.parse_specs(self.values)
64 
65         # return everything for an empty query.
66         if not qspecs:
67             return spack.store.db.query()
68 
69         # Return only matching stuff otherwise.
70         specs = set()
71         for spec in qspecs:
72             for s in spack.store.db.query(spec, **kwargs):
73                 specs.add(s)
74         return sorted(specs)
75 
76 
77 _arguments['constraint'] = Args(
78     'constraint', nargs='*', action=ConstraintAction,
79     help='Constraint to select a subset of installed packages')
80 
81 _arguments['module_type'] = Args(
82     '-m', '--module-type', help='Type of module files',
83     default='tcl', choices=spack.modules.module_types)
84 
85 _arguments['yes_to_all'] = Args(
86     '-y', '--yes-to-all', action='store_true', dest='yes_to_all',
87     help='Assume "yes" is the answer to every confirmation request.')
88 
89 _arguments['recurse_dependencies'] = Args(
90     '-r', '--dependencies', action='store_true', dest='recurse_dependencies',
91     help='Recursively traverse spec dependencies')
92 
93 _arguments['clean'] = Args(
94     '--clean', action='store_false', dest='dirty',
95     help='Clean environment before installing package.')
96 
97 _arguments['dirty'] = Args(
98     '--dirty', action='store_true', dest='dirty',
99     help='Do NOT clean environment before installing.')
100 
101 _arguments['long'] = Args(
102     '-l', '--long', action='store_true',
103     help='Show dependency hashes as well as versions.')
104 
105 _arguments['very_long'] = Args(
106     '-L', '--very-long', action='store_true',
107     help='Show full dependency hashes as well as versions.')
108
```

Path: `lib/spack/spack/cmd/find.py`
Content:
```
1 ##############################################################################
2 # Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
3 # Produced at the Lawrence Livermore National Laboratory.
4 #
5 # This file is part of Spack.
6 # Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
7 # LLNL-CODE-647188
8 #
9 # For details, see https://github.com/llnl/spack
10 # Please also see the LICENSE file for our notice and the LGPL.
11 #
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU Lesser General Public License (as
14 # published by the Free Software Foundation) version 2.1, February 1999.
15 #
16 # This program is distributed in the hope that it will be useful, but
17 # WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
19 # conditions of the GNU Lesser General Public License for more details.
20 #
21 # You should have received a copy of the GNU Lesser General Public
22 # License along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 ##############################################################################
25 import sys
26 
27 import llnl.util.tty as tty
28 import spack.cmd.common.arguments as arguments
29 
30 from spack.cmd import display_specs
31 
32 description = "Find installed spack packages"
33 
34 
35 def setup_parser(subparser):
36     format_group = subparser.add_mutually_exclusive_group()
37     format_group.add_argument('-s', '--short',
38                               action='store_const',
39                               dest='mode',
40                               const='short',
41                               default='short',
42                               help='Show only specs (default)')
43     format_group.add_argument('-p', '--paths',
44                               action='store_const',
45                               dest='mode',
46                               const='paths',
47                               help='Show paths to package install directories')
48     format_group.add_argument(
49         '-d', '--deps',
50         action='store_const',
51         dest='mode',
52         const='deps',
53         help='Show full dependency DAG of installed packages')
54 
55     arguments.add_common_arguments(subparser, ['long', 'very_long'])
56 
57     subparser.add_argument('-f', '--show-flags',
58                            action='store_true',
59                            dest='show_flags',
60                            help='Show spec compiler flags.')
61     implicit_explicit = subparser.add_mutually_exclusive_group()
62     implicit_explicit.add_argument(
63         '-e', '--explicit',
64         action='store_true',
65         help='Show only specs that were installed explicitly')
66     implicit_explicit.add_argument(
67         '-E', '--implicit',
68         action='store_true',
69         help='Show only specs that were installed as dependencies')
70     subparser.add_argument(
71         '-u', '--unknown',
72         action='store_true',
73         dest='unknown',
74         help='Show only specs Spack does not have a package for.')
75     subparser.add_argument(
76         '-m', '--missing',
77         action='store_true',
78         dest='missing',
79         help='Show missing dependencies as well as installed specs.')
80     subparser.add_argument(
81         '-v', '--variants',
82         action='store_true',
83         dest='variants',
84         help='Show variants in output (can be long)')
85     subparser.add_argument('-M', '--only-missing',
86                            action='store_true',
87                            dest='only_missing',
88                            help='Show only missing dependencies.')
89     subparser.add_argument('-N', '--namespace',
90                            action='store_true',
91                            help='Show fully qualified package names.')
92 
93     arguments.add_common_arguments(subparser, ['constraint'])
94 
95 
96 def query_arguments(args):
97     # Set up query arguments.
98     installed, known = True, any
99     if args.only_missing:
100         installed = False
101     elif args.missing:
102         installed = any
103     if args.unknown:
104         known = False
105     explicit = any
106     if args.explicit:
107         explicit = True
108     if args.implicit:
109         explicit = False
110     q_args = {'installed': installed, 'known': known, "explicit": explicit}
111     return q_args
112 
113 
114 def find(parser, args):
115     q_args = query_arguments(args)
116     query_specs = args.specs(**q_args)
117 
118     # Exit early if no package matches the constraint
119     if not query_specs and args.constraint:
120         msg = "No package matches the query: {0}".format(args.constraint)
121         tty.msg(msg)
122         return
123 
124     # Display the result
125     if sys.stdout.isatty():
126         tty.msg("%d installed packages." % len(query_specs))
127 
128     display_specs(query_specs,
129                   mode=args.mode,
130                   long=args.long,
131                   very_long=args.very_long,
132                   show_flags=args.show_flags,
133                   namespace=args.namespace,
134                   variants=args.variants)
135
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/lib/spack/spack/cmd/common/arguments.py b/lib/spack/spack/cmd/common/arguments.py
--- a/lib/spack/spack/cmd/common/arguments.py
+++ b/lib/spack/spack/cmd/common/arguments.py
@@ -75,7 +75,7 @@
 
 
 _arguments['constraint'] = Args(
-    'constraint', nargs='*', action=ConstraintAction,
+    'constraint', nargs=argparse.REMAINDER, action=ConstraintAction,
     help='Constraint to select a subset of installed packages')
 
 _arguments['module_type'] = Args(
diff --git a/lib/spack/spack/cmd/find.py b/lib/spack/spack/cmd/find.py
--- a/lib/spack/spack/cmd/find.py
+++ b/lib/spack/spack/cmd/find.py
@@ -117,7 +117,8 @@
 
     # Exit early if no package matches the constraint
     if not query_specs and args.constraint:
-        msg = "No package matches the query: {0}".format(args.constraint)
+        msg = "No package matches the query: {0}".format(
+            ' '.join(args.constraint))
         tty.msg(msg)
         return

{"golden_diff": "diff --git a/lib/spack/spack/cmd/common/arguments.py b/lib/spack/spack/cmd/common/arguments.py\n--- a/lib/spack/spack/cmd/common/arguments.py\n+++ b/lib/spack/spack/cmd/common/arguments.py\n@@ -75,7 +75,7 @@\n \n \n _arguments['constraint'] = Args(\n-    'constraint', nargs='*', action=ConstraintAction,\n+    'constraint', nargs=argparse.REMAINDER, action=ConstraintAction,\n     help='Constraint to select a subset of installed packages')\n \n _arguments['module_type'] = Args(\ndiff --git a/lib/spack/spack/cmd/find.py b/lib/spack/spack/cmd/find.py\n--- a/lib/spack/spack/cmd/find.py\n+++ b/lib/spack/spack/cmd/find.py\n@@ -117,7 +117,8 @@\n \n     # Exit early if no package matches the constraint\n     if not query_specs and args.constraint:\n-        msg = \"No package matches the query: {0}\".format(args.constraint)\n+        msg = \"No package matches the query: {0}\".format(\n+            ' '.join(args.constraint))\n         tty.msg(msg)\n         return\n", "issue": "spack find does not accept same specs as other commands\nThe following works:\r\n```\r\n$ spack find hdf5~mpi\r\n```\r\nbut the following equivalent command does not:\r\n```\r\n$ spack find hdf5 -mpi\r\nusage: spack find [-h] [-s | -p | -d] [-l] [-L] [-f] [-e | -E] [-u] [-m] [-v]\r\n                  [-M] [-N]\r\n                  [constraint [constraint ...]]\r\nspack find: error: argument -p/--paths: ignored explicit argument 'i'\r\n```\n", "before_files": [{"content": "##############################################################################\n# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.\n# Produced at the Lawrence Livermore National Laboratory.\n#\n# This file is part of Spack.\n# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.\n# LLNL-CODE-647188\n#\n# For details, see https://github.com/llnl/spack\n# Please also see the LICENSE file for our notice and the LGPL.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU Lesser General Public License (as\n# published by the Free Software Foundation) version 2.1, February 1999.\n#\n# This program is distributed in the hope that it will be useful, but\n# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and\n# conditions of the GNU Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this program; if not, write to the Free Software\n# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n##############################################################################\n\nimport argparse\n\nimport spack.cmd\nimport spack.store\nimport spack.modules\nfrom spack.util.pattern import Args\n__all__ = ['add_common_arguments']\n\n_arguments = {}\n\n\ndef add_common_arguments(parser, list_of_arguments):\n    for argument in list_of_arguments:\n        if argument not in _arguments:\n            message = 'Trying to add non existing argument \"{0}\" to a command'\n            raise KeyError(message.format(argument))\n        x = _arguments[argument]\n        parser.add_argument(*x.flags, **x.kwargs)\n\n\nclass ConstraintAction(argparse.Action):\n    \"\"\"Constructs a list of specs based on a constraint given on the command line\n\n    An instance of this class is supposed to be used as an argument action\n    in a parser. It will read a constraint and will attach a function to the\n    arguments that accepts optional keyword arguments.\n\n    To obtain the specs from a command the function must be called.\n    \"\"\"\n\n    def __call__(self, parser, namespace, values, option_string=None):\n        # Query specs from command line\n        self.values = values\n        namespace.constraint = values\n        namespace.specs = self._specs\n\n    def _specs(self, **kwargs):\n        qspecs = spack.cmd.parse_specs(self.values)\n\n        # return everything for an empty query.\n        if not qspecs:\n            return spack.store.db.query()\n\n        # Return only matching stuff otherwise.\n        specs = set()\n        for spec in qspecs:\n            for s in spack.store.db.query(spec, **kwargs):\n                specs.add(s)\n        return sorted(specs)\n\n\n_arguments['constraint'] = Args(\n    'constraint', nargs='*', action=ConstraintAction,\n    help='Constraint to select a subset of installed packages')\n\n_arguments['module_type'] = Args(\n    '-m', '--module-type', help='Type of module files',\n    default='tcl', choices=spack.modules.module_types)\n\n_arguments['yes_to_all'] = Args(\n    '-y', '--yes-to-all', action='store_true', dest='yes_to_all',\n    help='Assume \"yes\" is the answer to every confirmation request.')\n\n_arguments['recurse_dependencies'] = Args(\n    '-r', '--dependencies', action='store_true', dest='recurse_dependencies',\n    help='Recursively traverse spec dependencies')\n\n_arguments['clean'] = Args(\n    '--clean', action='store_false', dest='dirty',\n    help='Clean environment before installing package.')\n\n_arguments['dirty'] = Args(\n    '--dirty', action='store_true', dest='dirty',\n    help='Do NOT clean environment before installing.')\n\n_arguments['long'] = Args(\n    '-l', '--long', action='store_true',\n    help='Show dependency hashes as well as versions.')\n\n_arguments['very_long'] = Args(\n    '-L', '--very-long', action='store_true',\n    help='Show full dependency hashes as well as versions.')\n", "path": "lib/spack/spack/cmd/common/arguments.py"}, {"content": "##############################################################################\n# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.\n# Produced at the Lawrence Livermore National Laboratory.\n#\n# This file is part of Spack.\n# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.\n# LLNL-CODE-647188\n#\n# For details, see https://github.com/llnl/spack\n# Please also see the LICENSE file for our notice and the LGPL.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU Lesser General Public License (as\n# published by the Free Software Foundation) version 2.1, February 1999.\n#\n# This program is distributed in the hope that it will be useful, but\n# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and\n# conditions of the GNU Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this program; if not, write to the Free Software\n# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n##############################################################################\nimport sys\n\nimport llnl.util.tty as tty\nimport spack.cmd.common.arguments as arguments\n\nfrom spack.cmd import display_specs\n\ndescription = \"Find installed spack packages\"\n\n\ndef setup_parser(subparser):\n    format_group = subparser.add_mutually_exclusive_group()\n    format_group.add_argument('-s', '--short',\n                              action='store_const',\n                              dest='mode',\n                              const='short',\n                              default='short',\n                              help='Show only specs (default)')\n    format_group.add_argument('-p', '--paths',\n                              action='store_const',\n                              dest='mode',\n                              const='paths',\n                              help='Show paths to package install directories')\n    format_group.add_argument(\n        '-d', '--deps',\n        action='store_const',\n        dest='mode',\n        const='deps',\n        help='Show full dependency DAG of installed packages')\n\n    arguments.add_common_arguments(subparser, ['long', 'very_long'])\n\n    subparser.add_argument('-f', '--show-flags',\n                           action='store_true',\n                           dest='show_flags',\n                           help='Show spec compiler flags.')\n    implicit_explicit = subparser.add_mutually_exclusive_group()\n    implicit_explicit.add_argument(\n        '-e', '--explicit',\n        action='store_true',\n        help='Show only specs that were installed explicitly')\n    implicit_explicit.add_argument(\n        '-E', '--implicit',\n        action='store_true',\n        help='Show only specs that were installed as dependencies')\n    subparser.add_argument(\n        '-u', '--unknown',\n        action='store_true',\n        dest='unknown',\n        help='Show only specs Spack does not have a package for.')\n    subparser.add_argument(\n        '-m', '--missing',\n        action='store_true',\n        dest='missing',\n        help='Show missing dependencies as well as installed specs.')\n    subparser.add_argument(\n        '-v', '--variants',\n        action='store_true',\n        dest='variants',\n        help='Show variants in output (can be long)')\n    subparser.add_argument('-M', '--only-missing',\n                           action='store_true',\n                           dest='only_missing',\n                           help='Show only missing dependencies.')\n    subparser.add_argument('-N', '--namespace',\n                           action='store_true',\n                           help='Show fully qualified package names.')\n\n    arguments.add_common_arguments(subparser, ['constraint'])\n\n\ndef query_arguments(args):\n    # Set up query arguments.\n    installed, known = True, any\n    if args.only_missing:\n        installed = False\n    elif args.missing:\n        installed = any\n    if args.unknown:\n        known = False\n    explicit = any\n    if args.explicit:\n        explicit = True\n    if args.implicit:\n        explicit = False\n    q_args = {'installed': installed, 'known': known, \"explicit\": explicit}\n    return q_args\n\n\ndef find(parser, args):\n    q_args = query_arguments(args)\n    query_specs = args.specs(**q_args)\n\n    # Exit early if no package matches the constraint\n    if not query_specs and args.constraint:\n        msg = \"No package matches the query: {0}\".format(args.constraint)\n        tty.msg(msg)\n        return\n\n    # Display the result\n    if sys.stdout.isatty():\n        tty.msg(\"%d installed packages.\" % len(query_specs))\n\n    display_specs(query_specs,\n                  mode=args.mode,\n                  long=args.long,\n                  very_long=args.very_long,\n                  show_flags=args.show_flags,\n                  namespace=args.namespace,\n                  variants=args.variants)\n", "path": "lib/spack/spack/cmd/find.py"}], "after_files": [{"content": "##############################################################################\n# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.\n# Produced at the Lawrence Livermore National Laboratory.\n#\n# This file is part of Spack.\n# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.\n# LLNL-CODE-647188\n#\n# For details, see https://github.com/llnl/spack\n# Please also see the LICENSE file for our notice and the LGPL.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU Lesser General Public License (as\n# published by the Free Software Foundation) version 2.1, February 1999.\n#\n# This program is distributed in the hope that it will be useful, but\n# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and\n# conditions of the GNU Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this program; if not, write to the Free Software\n# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n##############################################################################\n\nimport argparse\n\nimport spack.cmd\nimport spack.store\nimport spack.modules\nfrom spack.util.pattern import Args\n__all__ = ['add_common_arguments']\n\n_arguments = {}\n\n\ndef add_common_arguments(parser, list_of_arguments):\n    for argument in list_of_arguments:\n        if argument not in _arguments:\n            message = 'Trying to add non existing argument \"{0}\" to a command'\n            raise KeyError(message.format(argument))\n        x = _arguments[argument]\n        parser.add_argument(*x.flags, **x.kwargs)\n\n\nclass ConstraintAction(argparse.Action):\n    \"\"\"Constructs a list of specs based on a constraint given on the command line\n\n    An instance of this class is supposed to be used as an argument action\n    in a parser. It will read a constraint and will attach a function to the\n    arguments that accepts optional keyword arguments.\n\n    To obtain the specs from a command the function must be called.\n    \"\"\"\n\n    def __call__(self, parser, namespace, values, option_string=None):\n        # Query specs from command line\n        self.values = values\n        namespace.constraint = values\n        namespace.specs = self._specs\n\n    def _specs(self, **kwargs):\n        qspecs = spack.cmd.parse_specs(self.values)\n\n        # return everything for an empty query.\n        if not qspecs:\n            return spack.store.db.query()\n\n        # Return only matching stuff otherwise.\n        specs = set()\n        for spec in qspecs:\n            for s in spack.store.db.query(spec, **kwargs):\n                specs.add(s)\n        return sorted(specs)\n\n\n_arguments['constraint'] = Args(\n    'constraint', nargs=argparse.REMAINDER, action=ConstraintAction,\n    help='Constraint to select a subset of installed packages')\n\n_arguments['module_type'] = Args(\n    '-m', '--module-type', help='Type of module files',\n    default='tcl', choices=spack.modules.module_types)\n\n_arguments['yes_to_all'] = Args(\n    '-y', '--yes-to-all', action='store_true', dest='yes_to_all',\n    help='Assume \"yes\" is the answer to every confirmation request.')\n\n_arguments['recurse_dependencies'] = Args(\n    '-r', '--dependencies', action='store_true', dest='recurse_dependencies',\n    help='Recursively traverse spec dependencies')\n\n_arguments['clean'] = Args(\n    '--clean', action='store_false', dest='dirty',\n    help='Clean environment before installing package.')\n\n_arguments['dirty'] = Args(\n    '--dirty', action='store_true', dest='dirty',\n    help='Do NOT clean environment before installing.')\n\n_arguments['long'] = Args(\n    '-l', '--long', action='store_true',\n    help='Show dependency hashes as well as versions.')\n\n_arguments['very_long'] = Args(\n    '-L', '--very-long', action='store_true',\n    help='Show full dependency hashes as well as versions.')\n", "path": "lib/spack/spack/cmd/common/arguments.py"}, {"content": "##############################################################################\n# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.\n# Produced at the Lawrence Livermore National Laboratory.\n#\n# This file is part of Spack.\n# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.\n# LLNL-CODE-647188\n#\n# For details, see https://github.com/llnl/spack\n# Please also see the LICENSE file for our notice and the LGPL.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU Lesser General Public License (as\n# published by the Free Software Foundation) version 2.1, February 1999.\n#\n# This program is distributed in the hope that it will be useful, but\n# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and\n# conditions of the GNU Lesser General Public License for more details.\n#\n# You should have received a copy of the GNU Lesser General Public\n# License along with this program; if not, write to the Free Software\n# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n##############################################################################\nimport sys\n\nimport llnl.util.tty as tty\nimport spack.cmd.common.arguments as arguments\n\nfrom spack.cmd import display_specs\n\ndescription = \"Find installed spack packages\"\n\n\ndef setup_parser(subparser):\n    format_group = subparser.add_mutually_exclusive_group()\n    format_group.add_argument('-s', '--short',\n                              action='store_const',\n                              dest='mode',\n                              const='short',\n                              default='short',\n                              help='Show only specs (default)')\n    format_group.add_argument('-p', '--paths',\n                              action='store_const',\n                              dest='mode',\n                              const='paths',\n                              help='Show paths to package install directories')\n    format_group.add_argument(\n        '-d', '--deps',\n        action='store_const',\n        dest='mode',\n        const='deps',\n        help='Show full dependency DAG of installed packages')\n\n    arguments.add_common_arguments(subparser, ['long', 'very_long'])\n\n    subparser.add_argument('-f', '--show-flags',\n                           action='store_true',\n                           dest='show_flags',\n                           help='Show spec compiler flags.')\n    implicit_explicit = subparser.add_mutually_exclusive_group()\n    implicit_explicit.add_argument(\n        '-e', '--explicit',\n        action='store_true',\n        help='Show only specs that were installed explicitly')\n    implicit_explicit.add_argument(\n        '-E', '--implicit',\n        action='store_true',\n        help='Show only specs that were installed as dependencies')\n    subparser.add_argument(\n        '-u', '--unknown',\n        action='store_true',\n        dest='unknown',\n        help='Show only specs Spack does not have a package for.')\n    subparser.add_argument(\n        '-m', '--missing',\n        action='store_true',\n        dest='missing',\n        help='Show missing dependencies as well as installed specs.')\n    subparser.add_argument(\n        '-v', '--variants',\n        action='store_true',\n        dest='variants',\n        help='Show variants in output (can be long)')\n    subparser.add_argument('-M', '--only-missing',\n                           action='store_true',\n                           dest='only_missing',\n                           help='Show only missing dependencies.')\n    subparser.add_argument('-N', '--namespace',\n                           action='store_true',\n                           help='Show fully qualified package names.')\n\n    arguments.add_common_arguments(subparser, ['constraint'])\n\n\ndef query_arguments(args):\n    # Set up query arguments.\n    installed, known = True, any\n    if args.only_missing:\n        installed = False\n    elif args.missing:\n        installed = any\n    if args.unknown:\n        known = False\n    explicit = any\n    if args.explicit:\n        explicit = True\n    if args.implicit:\n        explicit = False\n    q_args = {'installed': installed, 'known': known, \"explicit\": explicit}\n    return q_args\n\n\ndef find(parser, args):\n    q_args = query_arguments(args)\n    query_specs = args.specs(**q_args)\n\n    # Exit early if no package matches the constraint\n    if not query_specs and args.constraint:\n        msg = \"No package matches the query: {0}\".format(\n            ' '.join(args.constraint))\n        tty.msg(msg)\n        return\n\n    # Display the result\n    if sys.stdout.isatty():\n        tty.msg(\"%d installed packages.\" % len(query_specs))\n\n    display_specs(query_specs,\n                  mode=args.mode,\n                  long=args.long,\n                  very_long=args.very_long,\n                  show_flags=args.show_flags,\n                  namespace=args.namespace,\n                  variants=args.variants)\n", "path": "lib/spack/spack/cmd/find.py"}]}