Skip to content
Snippets Groups Projects
Commit eb5c6079 authored by Mel Zuser's avatar Mel Zuser
Browse files

Reduce default verbosity for running scripts

Closes #5508
parent 19468bfc
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TupleSections #-}
-- | cabal-install CLI command: run
--
......@@ -43,7 +44,7 @@ import Distribution.Simple.Command
import Distribution.Types.ComponentName
( showComponentName )
import Distribution.Verbosity
( normal )
( normal, silent )
import Distribution.Simple.Utils
( wrapText, die', info, notice )
import Distribution.Client.ProjectPlanning
......@@ -120,10 +121,12 @@ runCommand = CommandUI
runAction :: NixStyleFlags () -> [String] -> GlobalFlags -> IO ()
runAction flags@NixStyleFlags {..} targetAndArgs globalFlags
= withContextAndSelectors RejectNoTargets (Just ExeKind) flags targetStr globalFlags $ \targetCtx ctx targetSelectors -> do
baseCtx <- case targetCtx of
ProjectContext -> return ctx
GlobalContext -> return ctx
ScriptContext path exemeta -> updateContextAndWriteProjectFile ctx path exemeta
(baseCtx, defaultVerbosity) <- case targetCtx of
ProjectContext -> return (ctx, normal)
GlobalContext -> return (ctx, normal)
ScriptContext path exemeta -> (, silent) <$> updateContextAndWriteProjectFile ctx path exemeta
let verbosity = fromFlagOrDefault defaultVerbosity (configVerbosity configFlags)
buildCtx <-
runProjectPreBuildPhase verbosity baseCtx $ \elaboratedPlan -> do
......@@ -232,7 +235,6 @@ runAction flags@NixStyleFlags {..} targetAndArgs globalFlags
elaboratedPlan
}
where
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
(targetStr, args) = splitAt 1 targetAndArgs
-- | Used by the main CLI parser as heuristic to decide whether @cabal@ was
......
synopsis: Better support for scripts
packages: cabal-install
prs: #7851 #7925 #7938
issues: #7842 #7073 #6354 #6149
prs: #7851 #7925 #7938 #7990
issues: #7842 #7073 #6354 #6149 #5508
description: {
......@@ -14,5 +14,6 @@ description: {
- `cabal list-bin` now works with scripts
- The name of the generated script executable has been changed from "script" to
"cabal-script-<your-sanitized-script-name>" for easier process management.
- Reduce the default verbosity of scripts, so that the build output doesn't interfere with the script output.
}
......@@ -489,6 +489,21 @@ A note on targets: Whenever a command takes a script target and it matches the
name of another target, the other target is preferred. To load the script
instead pass it as an explicit path: ./script
By default, scripts are run at silent verbosity (``--verbose=0``). To show the
build output for a script either use the command
::
$ cabal v2-run --verbose=n path/to/script
or the interpreter line
::
#!/usr/bin/env -S cabal v2-run --verbose=n
For more information see :cfg-field:`verbose`
cabal v2-freeze
----------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment