colors
This commit is contained in:
parent
8356988d95
commit
8ac433e8d1
9 changed files with 58 additions and 33 deletions
|
@ -2,7 +2,7 @@
|
|||
--
|
||||
-- see: https://github.com/sol/hpack
|
||||
--
|
||||
-- hash: 1cf72e2df7c9707db3de5badabd66d0a2123d9260d2eff8bfa4e32ef4c449cfd
|
||||
-- hash: 2181d6cb75bcd17dab9a58fcfa594141af68c4c3e34050da6ce0beeb47bb7642
|
||||
|
||||
name: gpm
|
||||
version: 0.1.0.0
|
||||
|
@ -35,7 +35,8 @@ library
|
|||
default-extensions: OverloadedStrings NoImplicitPrelude ScopedTypeVariables Strict
|
||||
ghc-options: -O2 -Werror -Wall -Wcompat -Wincomplete-uni-patterns -Wredundant-constraints -Wnoncanonical-monad-instances
|
||||
build-depends:
|
||||
base >=4.8 && <5
|
||||
ansi-terminal
|
||||
, base >=4.8 && <5
|
||||
, directory
|
||||
, file-embed
|
||||
, foldl
|
||||
|
@ -54,7 +55,8 @@ executable gpm
|
|||
default-extensions: OverloadedStrings NoImplicitPrelude ScopedTypeVariables Strict
|
||||
ghc-options: -O2 -Werror -Wall -Wcompat -Wincomplete-uni-patterns -Wredundant-constraints -Wnoncanonical-monad-instances -threaded -rtsopts -with-rtsopts=-N -optP-Wno-nonportable-include-path
|
||||
build-depends:
|
||||
base >=4.8 && <5
|
||||
ansi-terminal
|
||||
, base >=4.8 && <5
|
||||
, directory
|
||||
, file-embed
|
||||
, foldl
|
||||
|
|
|
@ -24,6 +24,7 @@ ghc-options:
|
|||
- -Wnoncanonical-monad-instances
|
||||
dependencies:
|
||||
- base >=4.8 && <5
|
||||
- ansi-terminal
|
||||
- directory
|
||||
- file-embed
|
||||
- foldl
|
||||
|
|
|
@ -12,14 +12,13 @@ module GPM.Docs
|
|||
where
|
||||
|
||||
import Protolude
|
||||
import Turtle
|
||||
|
||||
import Data.FileEmbed (embedStringFile)
|
||||
|
||||
import GPM.Helpers (debug_)
|
||||
import GPM.Helpers (debug_,green)
|
||||
|
||||
init :: IO ()
|
||||
init = do
|
||||
echo "* wiki.org"
|
||||
green "* wiki.org"
|
||||
writeFile "wiki.org" $(embedStringFile "templates/wiki.org")
|
||||
debug_ "git add wiki.org"
|
||||
|
|
|
@ -14,14 +14,19 @@ module GPM.Helpers
|
|||
, getGitUser
|
||||
, inGPM
|
||||
, inDir
|
||||
, red
|
||||
, green
|
||||
, yellow
|
||||
)
|
||||
where
|
||||
|
||||
import qualified Control.Foldl as Fold
|
||||
import Protolude hiding (die)
|
||||
import qualified System.Directory as Directory
|
||||
import Turtle
|
||||
|
||||
import qualified Control.Foldl as Fold
|
||||
import qualified System.Directory as Directory
|
||||
import qualified System.Console.ANSI as Console
|
||||
|
||||
-- | 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)
|
||||
|
@ -69,3 +74,21 @@ inDir workDir action = do
|
|||
res <- action
|
||||
cd currPwd
|
||||
return res
|
||||
|
||||
|
||||
putTextColor :: Console.Color -> Text -> IO ()
|
||||
putTextColor color t = do
|
||||
Console.setSGR [ Console.SetColor Console.Foreground Console.Dull color
|
||||
, Console.SetConsoleIntensity Console.NormalIntensity
|
||||
]
|
||||
putText t
|
||||
Console.setSGR [Console.Reset]
|
||||
|
||||
green :: Text -> IO ()
|
||||
green = putTextColor Console.Green
|
||||
|
||||
yellow :: Text -> IO ()
|
||||
yellow = putTextColor Console.Yellow
|
||||
|
||||
red :: Text -> IO ()
|
||||
red = putTextColor Console.Red
|
||||
|
|
|
@ -11,13 +11,13 @@ module GPM.Init
|
|||
(init)
|
||||
where
|
||||
|
||||
import Protolude hiding (die,fold)
|
||||
import Protolude hiding (die, fold)
|
||||
import Turtle
|
||||
|
||||
import qualified Control.Foldl as Fold
|
||||
|
||||
import qualified GPM.Docs as Docs
|
||||
import GPM.Helpers (debug_)
|
||||
import GPM.Helpers (debug_, yellow)
|
||||
import qualified GPM.Issue as Issue
|
||||
import qualified GPM.Review as Review
|
||||
import qualified GPM.Serve as Serve
|
||||
|
@ -25,7 +25,7 @@ import qualified GPM.Serve as Serve
|
|||
-- | Init a repository with a new empty branch named @gpm@
|
||||
init :: IO ()
|
||||
init = do
|
||||
echo "# <GPM> -- Git Project Manager"
|
||||
yellow "# GPM -- Git Project Manager"
|
||||
mkNewEmptyBranch "gpm"
|
||||
Issue.init
|
||||
Docs.init
|
||||
|
@ -40,7 +40,7 @@ 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)"
|
||||
putText $ "Create a new branch " <> br <> " (be sure the branch " <> br <> " doesn't already exists)"
|
||||
debug_ $ "git checkout --orphan " <> br
|
||||
echo "cleanup the branch"
|
||||
debug_ "git rm --cached -r ."
|
||||
|
|
|
@ -140,7 +140,7 @@ interactiveNewIssue ni =
|
|||
ptot PriorityC = "C"
|
||||
|
||||
notEmpty :: Text -> Maybe Text
|
||||
notEmpty "" = Nothing
|
||||
notEmpty "" = Nothing
|
||||
notEmpty str = Just str
|
||||
|
||||
ask :: Text -> Text -> (Text -> a) -> IO a
|
||||
|
@ -175,7 +175,7 @@ gatherNewIssueInfos iss br = do
|
|||
|
||||
init :: IO ()
|
||||
init = do
|
||||
echo "* issue.org"
|
||||
green "* issue.org"
|
||||
writeFile "issues.org" $(embedStringFile "templates/issues.org")
|
||||
debug_ "git add issues.org"
|
||||
mktree "templates"
|
||||
|
|
|
@ -18,15 +18,16 @@ module GPM.Review
|
|||
)
|
||||
where
|
||||
|
||||
import Protolude hiding (ask, die, (%),stdout)
|
||||
import Protolude hiding (ask, die, stdout, (%))
|
||||
import Turtle
|
||||
|
||||
import Data.FileEmbed (embedStringFile)
|
||||
import GPM.Helpers (getGPMDataDir, debug_, getGitUser)
|
||||
import Text.Mustache
|
||||
import qualified Data.Text as Text
|
||||
import qualified Data.Char as Char
|
||||
import qualified Data.Char as Char
|
||||
import Data.FileEmbed (embedStringFile)
|
||||
import qualified Data.Text as Text
|
||||
import GPM.Helpers (debug_, getGPMDataDir, getGitUser, green,
|
||||
green)
|
||||
import qualified System.Directory as Directory
|
||||
import Text.Mustache
|
||||
|
||||
data ReviewCommand = ReviewStart ReviewOptions
|
||||
| ReviewCommit
|
||||
|
@ -42,6 +43,7 @@ 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
|
||||
|
@ -51,11 +53,10 @@ init = do
|
|||
writeFile "templates/new-review.org" $(embedStringFile "templates/new-review.org")
|
||||
debug_ "git add templates"
|
||||
|
||||
|
||||
-- | Command Line Options
|
||||
data ReviewOptions = ReviewOptions
|
||||
{ interactive :: Bool
|
||||
, newReview :: NewReview
|
||||
, newReview :: NewReview
|
||||
} deriving (Eq)
|
||||
|
||||
data NewReview =
|
||||
|
@ -212,8 +213,8 @@ showReview br = do
|
|||
reviewName <- getTmpReviewFile br
|
||||
mainReviewName <- getMainReviewFile
|
||||
putText "--------------------------------------------------------------------------------"
|
||||
putText $ format ("Review file: "%fp) reviewName
|
||||
putText $ format ("Main Review file: "%fp) mainReviewName
|
||||
green $ format ("Review file: "%fp) reviewName
|
||||
green $ format ("Main Review file: "%fp) mainReviewName
|
||||
putText "--------------------------------------------------------------------------------"
|
||||
stdout (input reviewName)
|
||||
putText "--------------------------------------------------------------------------------"
|
||||
|
@ -264,7 +265,7 @@ interactiveNewReview nr =
|
|||
<*> ask "description" "" notEmpty
|
||||
where
|
||||
notEmpty :: Text -> Maybe Text
|
||||
notEmpty "" = Nothing
|
||||
notEmpty "" = Nothing
|
||||
notEmpty str = Just str
|
||||
ask :: Text -> Text -> (Text -> a) -> IO a
|
||||
ask field ex tr = do
|
||||
|
|
|
@ -13,11 +13,10 @@ module GPM.Serve
|
|||
)
|
||||
where
|
||||
|
||||
import Protolude hiding (die, (%))
|
||||
import Protolude hiding (die, (%))
|
||||
import Turtle
|
||||
|
||||
import GPM.Helpers (debug, debug_, getGPMDataDir,
|
||||
inDir)
|
||||
import GPM.Helpers (debug, debug_, getGPMDataDir, inDir, green)
|
||||
|
||||
getPublicDir :: IO Turtle.FilePath
|
||||
getPublicDir = do
|
||||
|
@ -39,11 +38,10 @@ getPublicPrjDir = do
|
|||
let projectName = basename reporoot
|
||||
return (publicdir </> projectName)
|
||||
|
||||
|
||||
-- | init gpm branch to handle reviews
|
||||
init :: IO ()
|
||||
init = do
|
||||
echo "* server init"
|
||||
green "* server init"
|
||||
publicdir <- getPublicDir
|
||||
putText (format ("create dir: "%fp) publicdir)
|
||||
mktree publicdir
|
||||
|
@ -53,8 +51,9 @@ init = do
|
|||
output descriptionFile "Main repositories"
|
||||
repoRoot <- getProjectRoot
|
||||
publicProjectDir <- getPublicPrjDir
|
||||
putText (format ("rmtree " % fp) publicProjectDir)
|
||||
rmtree publicProjectDir
|
||||
whenM (testdir publicProjectDir) $ do
|
||||
putText (format ("rmtree " % fp) publicProjectDir)
|
||||
rmtree publicProjectDir
|
||||
debug_ (format ("git clone --bare "%fp%" "%fp)
|
||||
repoRoot
|
||||
publicProjectDir)
|
||||
|
|
|
@ -5,4 +5,4 @@
|
|||
:ASSIGNEE: {{assignee}}{{/assignee}}{{#reviewers}}
|
||||
:REQUESTED_REVIEWERS: {{reviewers}}{{/reviewers}}
|
||||
:END:
|
||||
{{description}}
|
||||
{{#description}}{{description}}{{/description}}
|
||||
|
|
Loading…
Reference in a new issue