mirror of https://github.com/pypa/pip
Modifies the outdated command to list command.
This commit is contained in:
parent
ff24b578ba
commit
0267e8a684
|
@ -8,13 +8,13 @@ from pip.req import InstallRequirement
|
|||
from pip.util import get_installed_distributions
|
||||
|
||||
|
||||
class OutdatedCommand(Command):
|
||||
name = 'outdated'
|
||||
class ListCommand(Command):
|
||||
name = 'list'
|
||||
usage = '%prog [OPTIONS]'
|
||||
summary = 'Output all currently installed outdated packages to stdout'
|
||||
summary = 'List all currently installed packages.'
|
||||
|
||||
def __init__(self):
|
||||
super(OutdatedCommand, self).__init__()
|
||||
super(ListCommand, self).__init__()
|
||||
self.parser.add_option(
|
||||
'-l', '--local',
|
||||
dest='local',
|
||||
|
@ -22,6 +22,12 @@ class OutdatedCommand(Command):
|
|||
default=False,
|
||||
help='If in a virtualenv, do not report'
|
||||
' globally-installed packages')
|
||||
self.parser.add_option(
|
||||
'-o', '--outdated',
|
||||
dest='outdated',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Output all currently installed outdated packages to stdout')
|
||||
self.parser.add_option(
|
||||
'-f', '--find-links',
|
||||
dest='find_links',
|
||||
|
@ -72,6 +78,10 @@ class OutdatedCommand(Command):
|
|||
mirrors=options.mirrors)
|
||||
|
||||
def run(self, options, args):
|
||||
if options.outdated:
|
||||
self.run_outdated(options, args)
|
||||
|
||||
def run_outdated(self, options, args):
|
||||
local_only = options.local
|
||||
index_urls = [options.index_url] + options.extra_index_urls
|
||||
if options.no_index:
|
||||
|
@ -115,4 +125,4 @@ class OutdatedCommand(Command):
|
|||
logger.notify('%s (CURRENT: %s LATEST: %s)' % (req.name, req.installed_version, remote_version))
|
||||
|
||||
|
||||
OutdatedCommand()
|
||||
ListCommand()
|
|
@ -32,10 +32,9 @@ def _check_output(result, expected):
|
|||
assert checker.check_output(expected, actual, ELLIPSIS), banner('EXPECTED')+expected+banner('ACTUAL')+actual+banner(6*'=')
|
||||
|
||||
|
||||
|
||||
def test_outdated_default():
|
||||
"""
|
||||
Test default behavor of oudated command
|
||||
Test default behavor of --outdated option in the list command
|
||||
"""
|
||||
|
||||
env = reset_env()
|
||||
|
@ -50,9 +49,9 @@ def test_outdated_default():
|
|||
simplejson_ver = total_re.search(str(result)).group(1)
|
||||
result = run_pip('search', 'INITools')
|
||||
initools_ver = total_re.search(str(result)).group(1)
|
||||
result = run_pip('outdated', expect_stderr=True)
|
||||
result = run_pip('list', '--outdated', expect_stderr=True)
|
||||
expected = textwrap.dedent("""\
|
||||
Script result: pip outdated
|
||||
Script result: pip list --outdated
|
||||
-- stdout: --------------------
|
||||
simplejson (CURRENT: 2.0.0 LATEST: %s)
|
||||
initools (CURRENT: 0.2 LATEST: %s)
|
Loading…
Reference in New Issue