Skip to content

Commit

Permalink
Merge pull request #6254 from commercialhaskell/re6250
Browse files Browse the repository at this point in the history
  • Loading branch information
mpilgrem authored Sep 23, 2023
2 parents 93da0ca + 7956279 commit ad0375e
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 80 deletions.
5 changes: 3 additions & 2 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Major changes:

Behavior changes:

* `stack list` outputs to standard output rather than to standard error.
* `stack list`, `stack templates` and `stack uninstall` output to the standard
output stream rather than to the standard error stream.

Other enhancements:

Expand Down Expand Up @@ -185,7 +186,7 @@ Behavior changes:
[Haskell Error Index](https://errors.haskell.org/) initiative, all Stack
error messages generated by Stack itself begin with an unique code in the
form `[S-nnnn]`, where `nnnn` is a four-digit number.
* Test suite executables that seek input on the standard input channel (`stdin`)
* Test suite executables that seek input on the standard input stream (`stdin`)
will not throw an exception. Previously, they would thow an exception,
consistent with Cabal's 'exitcode-stdio-1.0' test suite interface
specification. Pass the flag `--no-tests-allow-stdin` to `stack build` to
Expand Down
12 changes: 6 additions & 6 deletions doc/build_command.md
Original file line number Diff line number Diff line change
Expand Up @@ -555,14 +555,14 @@ package is targetted in a multi-package project (for example, using
`stack build <package_name>`).

* **One target package:** The build output for the target package is sent to the
standard error output stream of the console as it happens.
standard error stream of the console as it happens.

* **More than one target package:** The build output from GHC (as opposed to
from Stack) for each target package is sent to a log file for that package,
unless an error occurs that prevents that. At the end of the build, the
location of the directory containing the log files is reported. To also output
the contents of the log files to the standard error output stream of the
console at the end of the build, use Stack's `dump-logs` option. For further
the contents of the log files to the standard error stream of the console at
the end of the build, use Stack's `dump-logs` option. For further
information about that option, see the
[YAML configuration](yaml_configuration.md#dump-logs) documentation. The
default `dump-logs` mode is to output the contents of the log files that are
Expand Down Expand Up @@ -606,10 +606,10 @@ Default: Enabled
Cabal defines a test suite interface
['exitcode-stdio-1.0'](https://hackage.haskell.org/package/Cabal-syntax-3.8.1.0/docs/Distribution-Types-TestSuiteInterface.html#v:TestSuiteExeV1.0)
where the test suite takes the form of an executable and the executable takes
nothing on the standard input channel (`stdin`). Pass this flag to override that
specification and allow the executable to receive input on that channel. If you
nothing on the standard input stream (`stdin`). Pass this flag to override that
specification and allow the executable to receive input on that stream. If you
pass `--no-tests-allow-stdin` and the executable seeks input on the standard
input channel, an exception will be thown.
input stream, an exception will be thown.

## Examples

Expand Down
2 changes: 1 addition & 1 deletion doc/dot_command.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ graphs and the `dot` executable for drawing directed graphs. Graphviz is
available to [download](https://www.graphviz.org/download/) for Linux, Windows,
macOS and FreeBSD.

`stack dot` produces output, to the standard output channel, in the DOT language
`stack dot` produces output, to the standard output stream, in the DOT language
to represent the relationships between your packages and their dependencies.

By default:
Expand Down
6 changes: 3 additions & 3 deletions doc/global_flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ specific configuration [option](yaml_configuration.md#ghc-variant).
## `--hpack-numeric-version` flag

Pass the flag `--hpack-numeric-version` to cause Stack to report the numeric
version of its built-in Hpack library to standard output (e.g. `0.35.0`) and
quit.
version of its built-in Hpack library to the standard output stream (e.g.
`0.35.0`) and quit.

## `--[no-]install-ghc` flag

Expand Down Expand Up @@ -158,7 +158,7 @@ Stack can be configured to integrate with Nix. For further information, see
## `--numeric-version` flag

Pass the flag `--numeric-version` to cause Stack to report its numeric version
to standard output (e.g. `2.9.1`) and quit.
to the standard output stream (e.g. `2.9.1`) and quit.

## `--[no-]plan-in-log` flag

Expand Down
8 changes: 4 additions & 4 deletions doc/ide_command.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ stack ide packages [--stdout] [--cabal-files]

By default:

* its output is sent to the standard error channel. Pass the flag `--stdout` to
change to the standard output channel; and
* its output is sent to the standard error stream. Pass the flag `--stdout` to
change to the standard output stream; and
* the output is the package name (without its version). Pass the flag
`--cabal-files` to change to the full path to the package's Cabal file.

Expand All @@ -39,8 +39,8 @@ stack ide targets [--exes] [--tests] [--benchmarks] [--stdout]
or more of the flags `--exes`, `--tests` and `--benchmarks` to list only targets
of those component types.

By default, its output is sent to the standard error channel. Pass the flag
`--stdout` to change to the standard output channel.
By default, its output is sent to the standard error stream. Pass the flag
`--stdout` to change to the standard output stream.

For example, for the Stack project itself, command:

Expand Down
23 changes: 12 additions & 11 deletions doc/list_command.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@
stack list [PACKAGE]
~~~

`stack list <package_name>` will list the latest version of the package from
Hackage. If the package name cannot be found on Hackage, even after updating the
package index, suggestions (not necessarily good ones) will be made about the
intended package name.
`stack list <package_name>` will send to the standard output stream the latest
version of the package from Hackage. If the package name cannot be found on
Hackage, even after updating the package index, suggestions (not necessarily
good ones) will be made about the intended package name.

`stack --resolver <snapshot> list <package_name>` will list the version of the
package in the specified snapshot, unless the package comes with GHC on
Unix-like operating systems. If the package name cannot be found in the
snapshot, the command will fail, identifying only the package(s) that did not
appear in the snapshot.
`stack --resolver <snapshot> list <package_name>` will send to the standard
output stream the version of the package in the specified snapshot, unless the
package comes with GHC on Unix-like operating systems. If the package name
cannot be found in the snapshot, the command will fail, identifying only the
package(s) that did not appear in the snapshot.

More than one package name can be specified.

`stack --resolver <snapshot> list` will list all the packages in the specified
snapshot, except those which come with GHC on Unix-like operating systems.
`stack --resolver <snapshot> list` will send to the standard output stream a
list of all the packages in the specified snapshot, except those which come with
GHC on Unix-like operating systems.

For example:

Expand Down
4 changes: 2 additions & 2 deletions doc/templates_command.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
stack templates
~~~

`stack templates` provides information about project templates used with the
[`stack new` command](new_command.md).
`stack templates` provides information to the standard output stream about
project templates used with the [`stack new` command](new_command.md).

Project templates are specified in `.hsfiles` files. The format of those files
is documented at the
Expand Down
6 changes: 3 additions & 3 deletions doc/uninstall_command.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
stack uninstall
~~~

`stack uninstall` provides information about how to uninstall Stack or a
Stack-supplied tool (such as GHC or, on Windows, MSYS2). It does not
itself uninstall Stack or a Stack-supplied tool.
`stack uninstall` provides information to the standard output stream about how
to uninstall Stack or a Stack-supplied tool (such as GHC or, on Windows, MSYS2).
It does not itself uninstall Stack or a Stack-supplied tool.
8 changes: 4 additions & 4 deletions doc/yaml_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -796,8 +796,8 @@ unless an error occurs that prevents that. For further information, see the
documentation.

The value of the `dump-logs` key controls what, if any, log file content is sent
('dumped') to the standard error output stream of the console at the end of the
build. Possible values are:
('dumped') to the standard error stream of the console at the end of the build.
Possible values are:

~~~yaml
dump-logs: none # don't dump the content of any log files
Expand All @@ -810,8 +810,8 @@ At the command line, `--no-dump-logs` is equivalent to `dump-logs: none` and

If GHC reports an error during the build and a log file is created, that build
output will be included in the log file. Stack will also report errors during
building to the standard error output stream. That stream can be piped to a
file. For example, for a file named `stderr.log`:
building to the standard error stream. That stream can be piped to a file. For
example, for a file named `stderr.log`:

~~~text
stack --no-dump-logs --color always build --no-interleaved-output 2> stderr.log
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/ConfigCmd.hs
Original file line number Diff line number Diff line change
Expand Up @@ -364,4 +364,4 @@ cfgCmdEnv es = do
encodeUtf8Builder key <> ";\n"
escape '\'' = "'\"'\"'"
escape c = T.singleton c
hPutBuilder stdout $ Map.foldMapWithKey toLine actions
putBuilder $ Map.foldMapWithKey toLine actions
6 changes: 3 additions & 3 deletions src/Stack/IDE.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ import Stack.Types.SourceMap
( ProjectPackage (..), SMWanted (..), ppComponentsMaybe )
import System.IO ( putStrLn )

-- Type representing output channel choices for the @stack ide packages@ and
-- Type representing output stream choices for the @stack ide packages@ and
-- @stack ide targets@ commands.
data OutputStream
= OutputLogInfo
-- ^ To the same output channel as other log information.
-- ^ To the same output stream as other log information.
| OutputStdout
-- ^ To the standard output channel.
-- ^ To the standard output stream.

-- Type representing output choices for the @stack ide packages@ command.
data ListPackagesCmd
Expand Down
28 changes: 20 additions & 8 deletions src/Stack/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ module Stack.Prelude
, bugReport
, bugPrettyReport
, blankLine
, putUtf8Builder
, putBuilder
, ppException
, prettyThrowIO
, prettyThrowM
Expand All @@ -46,6 +48,7 @@ module Stack.Prelude
, bulletedList
, debugBracket
, defaultStyles
, displayWithColor
, encloseSep
, fill
, fillSep
Expand Down Expand Up @@ -104,14 +107,15 @@ import RIO.File as X hiding ( writeBinaryFileAtomic )
import RIO.PrettyPrint
( HasStylesUpdate (..), HasTerm (..), Pretty (..), Style (..)
, StyleDoc, (<+>), align, blankLine, bulletedList
, debugBracket, encloseSep, fill, fillSep, flow, hang, hcat
, hsep, indent, line, logLevelToStyle, mkNarrativeList
, parens, prettyDebug, prettyDebugL, prettyError
, prettyErrorL, prettyGeneric, prettyInfo, prettyInfoL
, prettyInfoS, prettyNote, prettyNoteL, prettyNoteS
, prettyWarn, prettyWarnL, prettyWarnNoIndent, prettyWarnS
, punctuate, sep, softbreak, softline, spacedBulletedList
, string, style, stylesUpdateL, useColorL, vsep
, debugBracket, displayWithColor, encloseSep, fill, fillSep
, flow, hang, hcat, hsep, indent, line, logLevelToStyle
, mkNarrativeList, parens, prettyDebug, prettyDebugL
, prettyError, prettyErrorL, prettyGeneric, prettyInfo
, prettyInfoL, prettyInfoS, prettyNote, prettyNoteL
, prettyNoteS, prettyWarn, prettyWarnL, prettyWarnNoIndent
, prettyWarnS, punctuate, sep, softbreak, softline
, spacedBulletedList, string, style, stylesUpdateL, useColorL
, vsep
)
import RIO.PrettyPrint.DefaultStyles (defaultStyles)
import RIO.PrettyPrint.PrettyException
Expand Down Expand Up @@ -350,3 +354,11 @@ bugRequest = "Please report this bug at Stack's repository."
-- | Maybe cons.
mcons :: Maybe a -> [a] -> [a]
mcons ma as = maybe as (:as) ma

-- | Write a 'Utf8Builder' to the standard output stream.
putUtf8Builder :: MonadIO m => Utf8Builder -> m ()
putUtf8Builder = putBuilder . getUtf8Builder

-- | Write a 'Builder' to the standard output stream.
putBuilder :: MonadIO m => Builder -> m ()
putBuilder = hPutBuilder stdout
4 changes: 2 additions & 2 deletions src/Stack/Templates.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Stack.Templates
) where

import qualified Data.ByteString.Lazy as LB
import qualified Data.Text as T
import qualified Data.Text.IO as T
import Network.HTTP.StackClient
( HttpException (..), getResponseBody, httpLbs, parseUrlThrow
, setGitHubHeaders
Expand Down Expand Up @@ -69,7 +69,7 @@ templatesHelp = do
(prettyThrowM . DownloadTemplatesHelpFailed)
case decodeUtf8' $ LB.toStrict $ getResponseBody resp of
Left err -> prettyThrowM $ TemplatesHelpEncodingInvalid url err
Right txt -> prettyInfo (string $ T.unpack txt)
Right txt -> liftIO $ T.putStrLn txt

-- | Default web URL to get the `stack templates` help output.
defaultTemplatesHelpUrl :: String
Expand Down
61 changes: 31 additions & 30 deletions src/Stack/Uninstall.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ module Stack.Uninstall
( uninstallCmd
) where

import Stack.Constants ( osIsWindows )
import Stack.Prelude
import Stack.Runners ( ShouldReexec (..), withConfig )
import Stack.Types.Config
( configL, configLocalBin, configLocalProgramsBase
, stackGlobalConfigL, stackRootL
)
import Stack.Types.Runner ( Runner )
import Stack.Constants ( osIsWindows )
import Stack.Prelude
import Stack.Runners ( ShouldReexec (..), withConfig )
import Stack.Types.Config
( configL, configLocalBin, configLocalProgramsBase
, stackGlobalConfigL, stackRootL
)
import Stack.Types.Runner ( Runner )

-- | Function underlying the @stack uninstall@ command. Display help for the
-- command.
Expand All @@ -28,8 +28,8 @@ uninstallCmd () = withConfig NoReexec $ do
globalConfig' = toStyleDoc globalConfig
programsDir' = toStyleDoc programsDir
localBinDir' = toStyleDoc localBinDir
prettyInfo $
vsep
putUtf8Builder =<< displayWithColor
( vsep
[ flow "To uninstall Stack, it should be sufficient to delete:"
, hang 4 $ fillSep
[ flow "(1) the directory containing Stack's tools"
Expand Down Expand Up @@ -59,26 +59,27 @@ uninstallCmd () = withConfig NoReexec $ do
, flow "directories in any Haskell projects that you have built."
]
]
<> blankLine
<> vsep
[ fillSep
[ flow "To uninstall completely a Stack-supplied tool (such as \
\GHC or, on Windows, MSYS2), delete from Stack's tools \
\directory"
, parens programsDir' <> ":"
]
, hang 4 $ fillSep
[ flow "(1) the tool's subdirectory;"
]
, hang 4 $ fillSep
[ flow "(2) the tool's archive file"
, parens (style File "<tool>.tar.xz") <> "; and"
]
, hang 4 $ fillSep
[ flow "(3) the file marking that the tool is installed"
, parens (style File "<tool>.installed") <> "."
]
]
<> blankLine
<> vsep
[ fillSep
[ flow "To uninstall completely a Stack-supplied tool (such as \
\GHC or, on Windows, MSYS2), delete from Stack's tools \
\directory"
, parens programsDir' <> ":"
]
, hang 4 $ fillSep
[ flow "(1) the tool's subdirectory;"
]
, hang 4 $ fillSep
[ flow "(2) the tool's archive file"
, parens (style File "<tool>.tar.xz") <> "; and"
]
, hang 4 $ fillSep
[ flow "(3) the file marking that the tool is installed"
, parens (style File "<tool>.installed") <> "."
]
]
)
where
styleShell = style Shell
howToFindStack
Expand Down

0 comments on commit ad0375e

Please sign in to comment.