use stderr to help scripting

This commit is contained in:
Yann Esposito (Yogsototh) 2018-10-16 22:58:32 +02:00
parent 57565e4235
commit 8a2783470d
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646
4 changed files with 9 additions and 14 deletions

View file

@ -44,8 +44,3 @@ parser = subcommand "init" "Initialize gpm" (pure Init)
<|> Serve <$> subcommand "serve"
"Serve the git to the web"
Serve.parseServeCommand
debug :: Text -> IO ()
debug cmd = do
putText cmd
stdout $ inshell cmd empty

View file

@ -31,7 +31,7 @@ import qualified System.Console.ANSI as Console
-- but also log the command to the console to minimize surprise
debug :: Text -> IO (Maybe Text)
debug cmd = do
putText cmd
putErrText cmd
fmap lineToText <$> _foldIO (inshell cmd empty) (Fold.generalize Fold.last)
-- | execute a shell script without stdin and without handling output

View file

@ -40,9 +40,9 @@ mkNewEmptyBranch br = sh $ do
clean <- fold (inshell "git status --porcelain" empty) Fold.null
if clean
then liftIO $ do
putText $ "Create a new branch " <> br <> " (be sure the branch " <> br <> " doesn't already exists)"
putErrText $ "Create a new branch " <> br <> " (be sure the branch " <> br <> " doesn't already exists)"
debug_ $ "git checkout --orphan " <> br
echo "cleanup the branch"
putErrText "cleanup the branch"
debug_ "git rm --cached -r ."
debug_ "git clean -fd"
else die "Please take care of pending modification and untracked files (you can use git stash --all)"

View file

@ -91,8 +91,8 @@ parseFullNewReview = do
nrUser <- optional $ optText "creator" 'c' "The user that created the review"
nrBranch <- optional $ optText "branch" 'b' "The branch related to the review"
nrDescription <- optional $ optText "descr" 'd' "Long review description"
pure NewReview { status = fromMaybe "TODO" nrStatus
, title = fromMaybe "Review Title" nrTitle
pure NewReview { status = fromMaybe "TODO" nrStatus
, title = fromMaybe "Review Title" nrTitle
, user = nrUser
, branch = nrBranch
, description = nrDescription
@ -182,10 +182,10 @@ communicateFp :: Turtle.FilePath -> IO ()
communicateFp filepath = do
let fptxt = format fp filepath
mainReviewName <- getMainReviewFile
putText $ "Main review file: " <> format fp mainReviewName
putText $ "Review file: " <> fptxt
putErrText $ "Main review file: " <> format fp mainReviewName
putErrText $ "Review file: " <> fptxt
export "GPM_REVIEW_FILE" fptxt
putText $ "export GPM_REVIEW_FILE=" <> fptxt
putErrText $ "export GPM_REVIEW_FILE=" <> fptxt
retrieveReview :: Text -> IO ()
retrieveReview br = do
@ -242,7 +242,7 @@ getTmpReviewFile br = do
createTmpNewReview :: NewReview -> Text -> IO ()
createTmpNewReview nr br = do
putText "DEBUG: create temporary file for the new review"
putErrText "Create temporary file for the new review"
ecompiled <- automaticCompile ["./templates"] "new-review.org"
case ecompiled of
Left pe -> do