##############################################################################
# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-647188
#
# For details, see https://github.com/llnl/spack
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License (as
# published by the Free Software Foundation) version 2.1, February 1999.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
# conditions of the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
import argparse

import llnl.util.tty as tty

import spack
import spack.store
import spack.cmd

description = "show installed packages that depend on another"
section = "basic"
level = "long"


def setup_parser(subparser):
    subparser.add_argument(
        'spec', nargs=argparse.REMAINDER,
        help="specs to list dependencies of")


def dependents(parser, args):
    specs = spack.cmd.parse_specs(args.spec)
    if len(specs) != 1:
        tty.die("spack dependents takes only one spec.")
    spec = spack.cmd.disambiguate_spec(specs[0])

    tty.msg("Dependents of %s" % spec.cformat('$_$@$%@$/'))
    deps = spack.store.db.installed_dependents(spec)
    if deps:
        spack.cmd.display_specs(deps)
    else:
        print("No dependents")

@@ -1271,16 +1271,56 @@
 y as tty
+%0Afrom llnl.util.tty.colify import colify
 %0A%0Aimport
@@ -1531,245 +1531,1590 @@
    '
-spec', nargs=argparse.REMAINDER,%0A        help=%22specs to list dependencies of%22)%0A%0A%0Adef dependents(parser, args):%0A    specs = spack.cmd.parse_specs(args.spec)%0A    if len(specs) != 1:%0A        tty.die(%22spack dependents takes only one spec.%22)%0A
+-a', '--all', action='store_true', default=False,%0A        help=%22List all potential dependents of the package instead of actual %22%0A        %22dependents of an installed spec%22)%0A    subparser.add_argument(%0A        'spec', nargs=argparse.REMAINDER,%0A        help=%22specs to list dependencies of%22)%0A%0A%0Adef inverted_dag():%0A    %22%22%22Returns inverted package DAG as adjacency lists.%22%22%22%0A    dag = %7B%7D%0A    for pkg in spack.repo.all_packages():%0A        dag.setdefault(pkg.name, set())%0A        for dep in pkg.dependencies:%0A            deps = %5Bdep%5D%0A%0A            # expand virtuals if necessary%0A            if spack.repo.is_virtual(dep):%0A                deps = %5Bs.name for s in spack.repo.providers_for(dep)%5D%0A%0A            for d in deps:%0A                dag.setdefault(d, set()).add(pkg.name)%0A    return dag%0A%0A%0Adef all_dependents(name, inverted_dag, dependents=None):%0A    if dependents is None:%0A        dependents = set()%0A%0A    if name in dependents:%0A        return set()%0A    dependents.add(name)%0A%0A    direct = inverted_dag%5Bname%5D%0A    for dname in direct:%0A        all_dependents(dname, inverted_dag, dependents)%0A    dependents.update(direct)%0A    return dependents%0A%0A%0Adef dependents(parser, args):%0A    specs = spack.cmd.parse_specs(args.spec)%0A    if len(specs) != 1:%0A        tty.die(%22spack dependents takes only one spec.%22)%0A%0A    if args.all:%0A        spec = specs%5B0%5D%0A        idag = inverted_dag()%0A%0A        dependents = all_dependents(spec.name, idag)%0A        dependents.remove(spec.name)%0A        if dependents:%0A            colify(sorted(dependents))%0A        else:%0A            print(%22No dependents%22)%0A%0A    else:%0A    
     
@@ -3159,24 +3159,28 @@
 cs%5B0%5D)%0A%0A    
+   
+ 
 tty.msg(%22Dep
@@ -3223,16 +3223,20 @@
 %25@$/'))%0A
+    
     deps
@@ -3280,24 +3280,28 @@
 s(spec)%0A    
+ 
+   
 if deps:%0A   
@@ -3305,16 +3305,20 @@
         
+  
+  
 spack.cm
@@ -3339,16 +3339,20 @@
 s(deps)%0A
+    
     else
@@ -3345,32 +3345,36 @@
 )%0A        else:%0A
+    
         print(%22N

Add --all argument to `spack dependents`