This repository has been archived by the owner on Mar 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
133 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,50 @@ | ||
{-# LANGUAGE NoImplicitPrelude #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Cmt.IO.CLI where | ||
module Cmt.IO.CLI | ||
( blank | ||
, message | ||
, mehssage | ||
, header | ||
, errorMessage | ||
) where | ||
|
||
import ClassyPrelude | ||
|
||
import Data.Text.IO (hPutStrLn) | ||
import System.Console.ANSI (Color (Blue, Magenta, Red, Yellow), ColorIntensity (Dull), | ||
ConsoleLayer (Foreground), SGR (Reset, SetColor), hSetSGR) | ||
|
||
blank :: IO () | ||
import Cmt.Types.App (App, settingsColourize) | ||
|
||
setSGR :: Handle -> [SGR] -> App | ||
setSGR hndl settings = do | ||
colourize <- asks settingsColourize | ||
when colourize $ lift (hSetSGR hndl settings) | ||
|
||
blank :: App | ||
blank = putStrLn "" | ||
|
||
message :: Text -> IO () | ||
message :: Text -> App | ||
message msg = do | ||
hSetSGR stdout [SetColor Foreground Dull Blue] | ||
hPutStrLn stdout msg | ||
hSetSGR stdout [Reset] | ||
setSGR stdout [SetColor Foreground Dull Blue] | ||
putStrLn msg | ||
setSGR stdout [Reset] | ||
|
||
mehssage :: Text -> IO () | ||
mehssage :: Text -> App | ||
mehssage msg = do | ||
hSetSGR stdout [SetColor Foreground Dull Yellow] | ||
hPutStrLn stdout msg | ||
hSetSGR stdout [Reset] | ||
setSGR stdout [SetColor Foreground Dull Yellow] | ||
putStrLn msg | ||
setSGR stdout [Reset] | ||
|
||
header :: Text -> IO () | ||
header :: Text -> App | ||
header msg = do | ||
hSetSGR stdout [SetColor Foreground Dull Magenta] | ||
hPutStrLn stdout $ "*** " ++ msg ++ " ***" | ||
hSetSGR stdout [Reset] | ||
setSGR stdout [SetColor Foreground Dull Magenta] | ||
putStrLn $ "*** " ++ msg ++ " ***" | ||
setSGR stdout [Reset] | ||
|
||
errorMessage :: Text -> IO () | ||
errorMessage :: Text -> App | ||
errorMessage msg = do | ||
hSetSGR stderr [SetColor Foreground Dull Red] | ||
hPutStrLn stderr msg | ||
hSetSGR stderr [Reset] | ||
setSGR stderr [SetColor Foreground Dull Red] | ||
lift $ hPutStrLn stderr msg | ||
setSGR stderr [Reset] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Cmt.Types.App | ||
( App | ||
, Settings(Settings) | ||
, defaultSettings | ||
, settingsDryRun | ||
, settingsColourize | ||
) where | ||
|
||
import ClassyPrelude | ||
|
||
data Settings = Settings | ||
{ settingsDryRun :: Bool | ||
, settingsColourize :: Bool | ||
} deriving (Eq, Show) | ||
|
||
type App = ReaderT Settings IO () | ||
|
||
defaultSettings :: Settings | ||
defaultSettings = Settings {settingsDryRun = False, settingsColourize = True} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,4 @@ data Next | |
| Version | ||
| ConfigLocation | ||
| Help | ||
| Error Text | ||
| DryRun Next | ||
deriving (Eq, Show) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
Usage: cmt [--dry-run] [message] | ||
Usage: cmt [--dry-run] [--no-color] [options | message] | ||
|
||
Settings: | ||
|
||
--dry-run Displays the commit message without committing | ||
--no-color Don't use bash colour codes in output | ||
|
||
Options: | ||
|
||
-h Display this help message | ||
-c Display location of .cmt file | ||
-v Display version number | ||
--dry-run Displays the commit message without committing | ||
--prev Runs previous attempt after failure/dry run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters