Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
864984cd
Unverified
Commit
864984cd
authored
Jan 13, 2017
by
Mikhail Glushenkov
Committed by
Mikhail Glushenkov
Jan 17, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'outdated': Support --quiet and --simple-output.
parent
b1fc79f8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
35 deletions
+89
-35
Cabal/doc/developing-packages.rst
Cabal/doc/developing-packages.rst
+45
-20
cabal-install/Distribution/Client/Outdated.hs
cabal-install/Distribution/Client/Outdated.hs
+30
-15
cabal-install/Distribution/Client/Setup.hs
cabal-install/Distribution/Client/Setup.hs
+14
-0
No files found.
Cabal/doc/developing-packages.rst
View file @
864984cd
...
...
@@ -1160,24 +1160,6 @@ configured to act on the freeze file (both old- and new-style) and
ignore
major
(
or
all
)
version
bumps
on
Hackage
for
a
subset
of
dependencies
.
Example
:
..
code
-
block
::
console
$
cabal
outdated
Outdated
dependencies
:
HTTP
==
4000.3.3
(
latest
:
4000.3.4
),
HUnit
==
1.3.1.1
(
latest
:
1.5.0.0
),
ListLike
==
4.2.1
(
latest
:
4.5
),
QuickCheck
==
2.8.2
(
latest
:
2.9.2
),
aeson
==
0.11.2.0
(
latest
:
1.1.0.0
)
$
cabal
outdated
--
ignore
=
HTTP
Outdated
dependencies
:
HUnit
==
1.3.1.1
(
latest
:
1.5.0.0
),
ListLike
==
4.2.1
(
latest
:
4.5
),
QuickCheck
==
2.8.2
(
latest
:
2.9.2
),
aeson
==
0.11.2.0
(
latest
:
1.1.0.0
)
$
cabal
outdated
--
ignore
=
HTTP
--
minor
=
HUnit
,
ListLike
Outdated
dependencies
:
HUnit
==
1.3.1.1
(
latest
:
1.3.1.2
),
QuickCheck
==
2.8.2
(
latest
:
2.9.2
),
aeson
==
0.11.2.0
(
latest
:
1.1.0.0
)
The
following
flags
are
supported
by
the
``
outdated
``
command
:
``--
freeze
-
file
``
...
...
@@ -1186,18 +1168,61 @@ The following flags are supported by the ``outdated`` command:
``--
new
-
freeze
-
file
``
Read
dependency
version
bounds
from
the
new
-
style
freeze
file
(``
cabal
.
project
.
freeze
``)
instead
of
the
package
description
file
.
``--
simple
-
output
``
Print
only
the
names
of
outdated
dependencies
,
one
per
line
.
``--
exit
-
code
``
Exit
with
a
non
-
zero
exit
code
when
there
are
outdated
dependencies
.
``-
q
,
--
quiet
``
Don
't print any output. Implies ``-v0`` and ``--exit-code``.
``--ignore`` *PACKAGENAMES*
Don'
t
warn
about
outdated
dependency
version
bounds
for
the
packages
in
this
list
.
``--
minor
``
*
PACKAGENAMES
*
Ignore major version bumps for these packages. E.g. if there'
s
a
version
2.0
of
a
package
``
pkg
``
on
Hackage
and
the
freeze
file
specifies
the
constraint
Ignore
major
version
bumps
for
these
packages
.
E
.
g
.
if
there
's a version 2.0
of
a package ``pkg`` on Hackage and the freeze file specifies the constraint
``pkg == 1.9``, ``cabal outdated --freeze --minor=pkg`` will only consider
the ``pkg`` outdated when there'
s
a
version
of
``
pkg
``
on
Hackage
satisfying
``
pkg
>
1.9
&&
<
2.0
``.
Examples
:
..
code
-
block
::
console
$
cd
/
some
/
package
$
cabal
outdated
Outdated
dependencies
:
haskell
-
src
-
exts
<
1.17
(
latest
:
1.19.1
)
language
-
javascript
<
0.6
(
latest
:
0.6.0.9
)
unix
==
2.7.2.0
(
latest
:
2.7.2.1
)
$
cabal
outdated
--
simple
-
output
haskell
-
src
-
exts
language
-
javascript
unix
$
cabal
outdated
--
ignore
=
haskell
-
src
-
exts
Outdated
dependencies
:
language
-
javascript
<
0.6
(
latest
:
0.6.0.9
)
unix
==
2.7.2.0
(
latest
:
2.7.2.1
)
$
cabal
outdated
--
ignore
=
haskell
-
src
-
exts
,
language
-
javascript
,
unix
All
dependencies
are
up
to
date
.
$
cabal
outdated
--
ignore
=
haskell
-
src
-
exts
,
language
-
javascript
,
unix
-
q
$
echo
$?
0
$
cd
/
some
/
other
/
package
$
cabal
outdated
--
freeze
-
file
Outdated
dependencies
:
HTTP
==
4000.3.3
(
latest
:
4000.3.4
)
HUnit
==
1.3.1.1
(
latest
:
1.5.0.0
)
$
cabal
outdated
--
freeze
-
file
--
ignore
=
HTTP
--
minor
=
HUnit
Outdated
dependencies
:
HUnit
==
1.3.1.1
(
latest
:
1.3.1.2
)
Executables
^^^^^^^^^^^
...
...
cabal-install/Distribution/Client/Outdated.hs
View file @
864984cd
...
...
@@ -16,7 +16,7 @@ import Distribution.Client.IndexUtils as IndexUtils
import
Distribution.Client.Compat.Prelude
import
Distribution.Client.ProjectConfig
import
Distribution.Client.RebuildMonad
import
Distribution.Client.Setup
import
Distribution.Client.Setup
hiding
(
quiet
)
import
Distribution.Client.Targets
import
Distribution.Client.Types
import
Distribution.Solver.Types.PackageConstraint
...
...
@@ -37,7 +37,7 @@ import Distribution.Text (display)
import
Distribution.Types.ComponentRequestedSpec
(
ComponentRequestedSpec
(
..
))
import
Distribution.Types.Dependency
(
Dependency
(
..
),
depPkgName
,
simplifyDependency
)
import
Distribution.Verbosity
(
Verbosity
)
import
Distribution.Verbosity
(
Verbosity
,
silent
)
import
Distribution.Version
(
Version
,
LowerBound
(
..
),
UpperBound
(
..
)
,
asVersionIntervals
,
majorBoundVersion
)
...
...
@@ -50,31 +50,45 @@ import System.Exit (exitFailure)
outdated
::
Verbosity
->
OutdatedFlags
->
RepoContext
->
Compiler
->
Platform
->
IO
()
outdated
verbosity
outdatedFlags
repoContext
comp
platform
=
do
sourcePkgDb
<-
IndexUtils
.
getSourcePackages
verbosity
repoContext
outdated
verbosity0
outdatedFlags
repoContext
comp
platform
=
do
let
freezeFile
=
fromFlagOrDefault
False
(
outdatedFreezeFile
outdatedFlags
)
newFreezeFile
=
fromFlagOrDefault
False
(
outdatedNewFreezeFile
outdatedFlags
)
exitCode
=
fromFlagOrDefault
False
(
outdatedExitCode
outdatedFlags
)
newFreezeFile
=
fromFlagOrDefault
False
(
outdatedNewFreezeFile
outdatedFlags
)
simpleOutput
=
fromFlagOrDefault
False
(
outdatedSimpleOutput
outdatedFlags
)
quiet
=
fromFlagOrDefault
False
(
outdatedQuiet
outdatedFlags
)
exitCode
=
fromFlagOrDefault
quiet
(
outdatedExitCode
outdatedFlags
)
ignore
=
S
.
fromList
(
outdatedIgnore
outdatedFlags
)
minor
=
S
.
fromList
(
outdatedMinor
outdatedFlags
)
pkgIndex
=
packageIndex
sourcePkgDb
verbosity
=
if
quiet
then
silent
else
verbosity0
sourcePkgDb
<-
IndexUtils
.
getSourcePackages
verbosity
repoContext
let
pkgIndex
=
packageIndex
sourcePkgDb
deps
<-
if
freezeFile
then
depsFromFreezeFile
verbosity
else
if
newFreezeFile
then
depsFromNewFreezeFile
verbosity
else
depsFromPkgDesc
verbosity
comp
platform
let
outdatedDeps
=
listOutdated
deps
pkgIndex
ignore
minor
if
(
not
.
null
$
outdatedDeps
)
then
notice
verbosity
(
"Outdated dependencies: "
++
intercalate
", "
(
map
(
\
(
d
,
v
)
->
display
d
++
" (latest: "
++
display
v
++
")"
)
outdatedDeps
))
else
notice
verbosity
"All dependencies are up to date."
when
(
not
quiet
)
$
showResult
verbosity
outdatedDeps
simpleOutput
if
(
exitCode
&&
(
not
.
null
$
outdatedDeps
))
then
exitFailure
else
return
()
-- | Print either the list of all outdated dependencies, or a message
-- that there are none.
showResult
::
Verbosity
->
[(
Dependency
,
Version
)]
->
Bool
->
IO
()
showResult
verbosity
outdatedDeps
simpleOutput
=
if
(
not
.
null
$
outdatedDeps
)
then
do
when
(
not
simpleOutput
)
$
notice
verbosity
"Outdated dependencies:"
for_
outdatedDeps
$
\
(
d
@
(
Dependency
pn
_
),
v
)
->
let
outdatedDep
=
if
simpleOutput
then
display
pn
else
display
d
++
" (latest: "
++
display
v
++
")"
in
notice
verbosity
outdatedDep
else
notice
verbosity
"All dependencies are up to date."
-- | Convert a list of 'UserConstraint's to a 'Dependency' list.
userConstraintsToDependencies
::
[
UserConstraint
]
->
[
Dependency
]
userConstraintsToDependencies
ucnstrs
=
...
...
@@ -99,7 +113,8 @@ depsFromNewFreezeFile verbosity = do
let
ucnstrs
=
map
fst
.
projectConfigConstraints
.
projectConfigShared
$
projectConfig
deps
=
userConstraintsToDependencies
ucnstrs
debug
verbosity
"Reading the list of dependencies from the new-style freeze file"
debug
verbosity
"Reading the list of dependencies from the new-style freeze file"
return
deps
-- | Read the list of dependencies from the package description.
...
...
cabal-install/Distribution/Client/Setup.hs
View file @
864984cd
...
...
@@ -865,7 +865,9 @@ data OutdatedFlags = OutdatedFlags {
outdatedVerbosity
::
Flag
Verbosity
,
outdatedFreezeFile
::
Flag
Bool
,
outdatedNewFreezeFile
::
Flag
Bool
,
outdatedSimpleOutput
::
Flag
Bool
,
outdatedExitCode
::
Flag
Bool
,
outdatedQuiet
::
Flag
Bool
,
outdatedIgnore
::
[
PackageName
],
outdatedMinor
::
[
PackageName
]
}
...
...
@@ -875,7 +877,9 @@ defaultOutdatedFlags = OutdatedFlags {
outdatedVerbosity
=
toFlag
normal
,
outdatedFreezeFile
=
mempty
,
outdatedNewFreezeFile
=
mempty
,
outdatedSimpleOutput
=
mempty
,
outdatedExitCode
=
mempty
,
outdatedQuiet
=
mempty
,
outdatedIgnore
=
mempty
,
outdatedMinor
=
mempty
}
...
...
@@ -904,11 +908,21 @@ outdatedCommand = CommandUI {
outdatedNewFreezeFile
(
\
v
flags
->
flags
{
outdatedNewFreezeFile
=
v
})
trueArg
,
option
[]
[
"simple-output"
]
"Only print names of outdated dependencies, one per line"
outdatedSimpleOutput
(
\
v
flags
->
flags
{
outdatedSimpleOutput
=
v
})
trueArg
,
option
[]
[
"exit-code"
]
"Exit with non-zero when there are outdated dependencies"
outdatedExitCode
(
\
v
flags
->
flags
{
outdatedExitCode
=
v
})
trueArg
,
option
[
'q'
]
[
"quiet"
]
"Don't print any output. Implies '--exit-code' and '-v0'"
outdatedQuiet
(
\
v
flags
->
flags
{
outdatedQuiet
=
v
})
trueArg
,
option
[]
[
"ignore"
]
"Packages to ignore"
outdatedIgnore
(
\
v
flags
->
flags
{
outdatedIgnore
=
v
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment