cleaning
This commit is contained in:
parent
8a2783470d
commit
a79af4e822
3 changed files with 28 additions and 17 deletions
|
@ -9,7 +9,7 @@ Maintainer : yann.esposito@gmail.com
|
|||
module GPM
|
||||
where
|
||||
|
||||
import Protolude hiding (stdout)
|
||||
import Protolude
|
||||
import Turtle
|
||||
|
||||
|
||||
|
|
|
@ -24,14 +24,20 @@ import Protolude hiding (die)
|
|||
import Turtle
|
||||
|
||||
import qualified Control.Foldl as Fold
|
||||
import qualified System.Directory as Directory
|
||||
import qualified System.Console.ANSI as Console
|
||||
import qualified System.Directory as Directory
|
||||
import qualified System.IO
|
||||
|
||||
-- | execute a shell script and return the last line as text
|
||||
-- but also log the command to the console to minimize surprise
|
||||
debug :: Text -> IO (Maybe Text)
|
||||
debug cmd = do
|
||||
putErrText cmd
|
||||
Console.setSGR [ Console.SetColor Console.Foreground Console.Dull Console.Cyan
|
||||
, Console.SetItalicized True
|
||||
]
|
||||
putErrText (" " <> cmd)
|
||||
Console.setSGR [ Console.Reset ]
|
||||
System.IO.hFlush System.IO.stderr
|
||||
fmap lineToText <$> _foldIO (inshell cmd empty) (Fold.generalize Fold.last)
|
||||
|
||||
-- | execute a shell script without stdin and without handling output
|
||||
|
@ -78,11 +84,10 @@ inDir workDir action = do
|
|||
|
||||
putTextColor :: Console.Color -> Text -> IO ()
|
||||
putTextColor color t = do
|
||||
Console.setSGR [ Console.SetColor Console.Foreground Console.Dull color
|
||||
, Console.SetConsoleIntensity Console.NormalIntensity
|
||||
]
|
||||
Console.setSGR [ Console.SetColor Console.Foreground Console.Dull color ]
|
||||
putText t
|
||||
Console.setSGR [ Console.Reset ]
|
||||
System.IO.hFlush System.IO.stdout
|
||||
|
||||
green :: Text -> IO ()
|
||||
green = putTextColor Console.Green
|
||||
|
|
|
@ -43,15 +43,21 @@ data ReviewCommand = ReviewStart ReviewOptions
|
|||
-- | init gpm branch to handle reviews
|
||||
init :: IO ()
|
||||
init = do
|
||||
green "* Init Reviews support"
|
||||
let fic = "reviews" </> "write-contributing-yogsototh.org"
|
||||
mktree "reviews"
|
||||
putText $ format ("* "%fp) fic
|
||||
green "* reviews.org"
|
||||
putText " create some example review for inspiration"
|
||||
let reviewDir = "reviews"
|
||||
mktree reviewDir
|
||||
let fic = reviewDir </> "write-contributing-yogsototh.org"
|
||||
putText $ format (" "%fp) fic
|
||||
writeFile (toS (format fp fic)) $(embedStringFile "templates/review.org")
|
||||
debug_ "git add reviews"
|
||||
mktree "templates"
|
||||
writeFile "templates/new-review.org" $(embedStringFile "templates/new-review.org")
|
||||
debug_ "git add templates"
|
||||
debug_ (toS (format ("git add "%fp) reviewDir))
|
||||
putText " create some review templates"
|
||||
let templateDir = "templates"
|
||||
templateFic = templateDir </> "new-review.org"
|
||||
mktree templateDir
|
||||
writeFile (toS (format fp templateFic)) $(embedStringFile "templates/new-review.org")
|
||||
putText $ format (" "%fp) templateFic
|
||||
debug_ (toS (format ("git add "%fp) templateDir))
|
||||
|
||||
-- | Command Line Options
|
||||
data ReviewOptions = ReviewOptions
|
||||
|
|
Loading…
Reference in a new issue