From 8a2783470d3d06a9c012e1fb7b09854f43a3a413 Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Tue, 16 Oct 2018 22:58:32 +0200 Subject: [PATCH] use stderr to help scripting --- src/GPM.hs | 5 ----- src/GPM/Helpers.hs | 2 +- src/GPM/Init.hs | 4 ++-- src/GPM/Review.hs | 12 ++++++------ 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/GPM.hs b/src/GPM.hs index 12406e4..c79ac1a 100755 --- a/src/GPM.hs +++ b/src/GPM.hs @@ -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 diff --git a/src/GPM/Helpers.hs b/src/GPM/Helpers.hs index 281fa1f..b5ea9e3 100644 --- a/src/GPM/Helpers.hs +++ b/src/GPM/Helpers.hs @@ -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 diff --git a/src/GPM/Init.hs b/src/GPM/Init.hs index ff78c1f..f0a4135 100644 --- a/src/GPM/Init.hs +++ b/src/GPM/Init.hs @@ -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)" diff --git a/src/GPM/Review.hs b/src/GPM/Review.hs index 65ec381..f3fa4b2 100644 --- a/src/GPM/Review.hs +++ b/src/GPM/Review.hs @@ -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