module GitHUD.Terminal.Prompt (
buildPromptWithConfig
, resetPromptAtBeginning
, addGitRepoIndicator
, addNoTrackedUpstreamIndicator
, addMergeBranchCommits
, addLocalBranchName
, addLocalCommits
, addRepoState
, addStashes
, buildPrompt
) where
import Control.Applicative ((<$>))
import Control.Monad (when)
import Control.Monad.Writer (runWriterT, tell)
import GitHUD.Config.Types
import GitHUD.Git.Types
import GitHUD.Terminal.Base
import GitHUD.Terminal.Types
import GitHUD.Types
buildPromptWithConfig :: TerminalState
buildPromptWithConfig :: TerminalState
buildPromptWithConfig = do
(()
_, Prompt
prompt) <- WriterT Prompt (Reader OutputConfig) ()
-> Reader OutputConfig ((), Prompt)
forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
runWriterT WriterT Prompt (Reader OutputConfig) ()
buildPrompt
Prompt -> TerminalState
forall (m :: * -> *) a. Monad m => a -> m a
return Prompt
prompt
buildPrompt :: ShellOutput
buildPrompt :: WriterT Prompt (Reader OutputConfig) ()
buildPrompt = do
Config
config <- WriterT Prompt (Reader OutputConfig) Config
forall (m :: * -> *). MonadReader OutputConfig m => m Config
askConfig
GitRepoState
repoState <- WriterT Prompt (Reader OutputConfig) GitRepoState
forall (m :: * -> *). MonadReader OutputConfig m => m GitRepoState
askRepoState
let branch :: Prompt
branch = GitRepoState -> Prompt
gitLocalBranch GitRepoState
repoState
WriterT Prompt (Reader OutputConfig) ()
resetPromptAtBeginning
Bool
-> WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Config -> Bool
confShowPartRepoIndicator Config
config) WriterT Prompt (Reader OutputConfig) ()
addGitRepoIndicator
Bool
-> WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Prompt -> Config -> Bool
showMergeBranchIndicator Prompt
branch Config
config) WriterT Prompt (Reader OutputConfig) ()
addNoTrackedUpstreamIndicator
Bool
-> WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Prompt -> Config -> Bool
showMergeBranchIndicator Prompt
branch Config
config) WriterT Prompt (Reader OutputConfig) ()
addMergeBranchCommits
Bool
-> WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Config -> Bool
confShowPartLocalBranch Config
config) WriterT Prompt (Reader OutputConfig) ()
addLocalBranchName
Bool
-> WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Config -> Bool
confShowPartCommitsToOrigin Config
config) WriterT Prompt (Reader OutputConfig) ()
addLocalCommits
Bool
-> WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Config -> Bool
confShowPartLocalChangesState Config
config) WriterT Prompt (Reader OutputConfig) ()
addRepoState
Bool
-> WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Config -> Bool
confShowPartStashes Config
config) WriterT Prompt (Reader OutputConfig) ()
addStashes
() -> WriterT Prompt (Reader OutputConfig) ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
showMergeBranchIndicator :: String -> Config -> Bool
showMergeBranchIndicator :: Prompt -> Config -> Bool
showMergeBranchIndicator Prompt
branch Config
config =
(Config -> Bool
confShowPartMergeBranchCommitsDiff Config
config) Bool -> Bool -> Bool
&&
(Bool -> Bool
not (Prompt
branch Prompt -> [Prompt] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` (Config -> [Prompt]
confMergeBranchIgnoreBranches Config
config)))
resetPromptAtBeginning :: ShellOutput
resetPromptAtBeginning :: WriterT Prompt (Reader OutputConfig) ()
resetPromptAtBeginning =
(Shell -> Prompt
endColorMarker (Shell -> Prompt)
-> WriterT Prompt (Reader OutputConfig) Shell
-> WriterT Prompt (Reader OutputConfig) Prompt
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> WriterT Prompt (Reader OutputConfig) Shell
forall (m :: * -> *). MonadReader OutputConfig m => m Shell
askShell) WriterT Prompt (Reader OutputConfig) Prompt
-> (Prompt -> WriterT Prompt (Reader OutputConfig) ())
-> WriterT Prompt (Reader OutputConfig) ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell
addGitRepoIndicator :: ShellOutput
addGitRepoIndicator :: WriterT Prompt (Reader OutputConfig) ()
addGitRepoIndicator = do
Config
config <- WriterT Prompt (Reader OutputConfig) Config
forall (m :: * -> *). MonadReader OutputConfig m => m Config
askConfig
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell (Prompt -> WriterT Prompt (Reader OutputConfig) ())
-> Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall a b. (a -> b) -> a -> b
$ Config -> Prompt
confRepoIndicator Config
config
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell Prompt
" "
addNoTrackedUpstreamIndicator :: ShellOutput
addNoTrackedUpstreamIndicator :: WriterT Prompt (Reader OutputConfig) ()
addNoTrackedUpstreamIndicator = do
GitRepoState
repoState <- WriterT Prompt (Reader OutputConfig) GitRepoState
forall (m :: * -> *). MonadReader OutputConfig m => m GitRepoState
askRepoState
Config
config <- WriterT Prompt (Reader OutputConfig) Config
forall (m :: * -> *). MonadReader OutputConfig m => m Config
askConfig
Bool
-> WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (GitRepoState -> Prompt
gitRemoteTrackingBranch GitRepoState
repoState Prompt -> Prompt -> Bool
forall a. Eq a => a -> a -> Bool
== Prompt
"") (WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ())
-> WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ()
forall a b. (a -> b) -> a -> b
$ do
Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
tellStringInColor
(Config -> Color
confNoTrackedUpstreamStringColor Config
config)
(Config -> ColorIntensity
confNoTrackedUpstreamStringIntensity Config
config)
(Config -> Prompt
confNoTrackedUpstreamString Config
config)
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell Prompt
" "
Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
tellStringInColor
(Config -> Color
confNoTrackedUpstreamIndicatorColor Config
config)
(Config -> ColorIntensity
confNoTrackedUpstreamIndicatorIntensity Config
config)
(Config -> Prompt
confNoTrackedUpstreamIndicator Config
config)
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell Prompt
" "
() -> WriterT Prompt (Reader OutputConfig) ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
addMergeBranchCommits :: ShellOutput
addMergeBranchCommits :: WriterT Prompt (Reader OutputConfig) ()
addMergeBranchCommits = do
GitRepoState
repoState <- WriterT Prompt (Reader OutputConfig) GitRepoState
forall (m :: * -> *). MonadReader OutputConfig m => m GitRepoState
askRepoState
Config
config <- WriterT Prompt (Reader OutputConfig) Config
forall (m :: * -> *). MonadReader OutputConfig m => m Config
askConfig
let push :: Int
push = GitRepoState -> Int
gitMergeBranchCommitsToPush GitRepoState
repoState
let pull :: Int
pull = GitRepoState -> Int
gitMergeBranchCommitsToPull GitRepoState
repoState
if (Int
push Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0) Bool -> Bool -> Bool
&& (Int
pull Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0)
then do
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell (Config -> Prompt
confMergeBranchCommitsIndicator Config
config)
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell Prompt
" "
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell (Prompt -> WriterT Prompt (Reader OutputConfig) ())
-> (Int -> Prompt)
-> Int
-> WriterT Prompt (Reader OutputConfig) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Prompt
forall a. Show a => a -> Prompt
show (Int -> WriterT Prompt (Reader OutputConfig) ())
-> Int -> WriterT Prompt (Reader OutputConfig) ()
forall a b. (a -> b) -> a -> b
$ Int
pull
Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
tellStringInColor Color
Green ColorIntensity
Vivid (Config -> Prompt
confMergeBranchCommitsBothPullPush Config
config)
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell (Prompt -> WriterT Prompt (Reader OutputConfig) ())
-> (Int -> Prompt)
-> Int
-> WriterT Prompt (Reader OutputConfig) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Prompt
forall a. Show a => a -> Prompt
show (Int -> WriterT Prompt (Reader OutputConfig) ())
-> Int -> WriterT Prompt (Reader OutputConfig) ()
forall a b. (a -> b) -> a -> b
$ Int
push
else (
if (Int
pull Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0)
then do
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell (Config -> Prompt
confMergeBranchCommitsIndicator Config
config)
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell Prompt
" "
Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
tellStringInColor Color
Green ColorIntensity
Vivid (Config -> Prompt
confMergeBranchCommitsOnlyPull Config
config)
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell Prompt
" "
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell (Prompt -> WriterT Prompt (Reader OutputConfig) ())
-> (Int -> Prompt)
-> Int
-> WriterT Prompt (Reader OutputConfig) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Prompt
forall a. Show a => a -> Prompt
show (Int -> WriterT Prompt (Reader OutputConfig) ())
-> Int -> WriterT Prompt (Reader OutputConfig) ()
forall a b. (a -> b) -> a -> b
$ Int
pull
else (
Bool
-> WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Int
push Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0) (WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ())
-> WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ()
forall a b. (a -> b) -> a -> b
$ do
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell (Config -> Prompt
confMergeBranchCommitsIndicator Config
config)
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell Prompt
" "
Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
tellStringInColor Color
Green ColorIntensity
Vivid (Config -> Prompt
confMergeBranchCommitsOnlyPush Config
config)
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell Prompt
" "
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell (Prompt -> WriterT Prompt (Reader OutputConfig) ())
-> (Int -> Prompt)
-> Int
-> WriterT Prompt (Reader OutputConfig) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Prompt
forall a. Show a => a -> Prompt
show (Int -> WriterT Prompt (Reader OutputConfig) ())
-> Int -> WriterT Prompt (Reader OutputConfig) ()
forall a b. (a -> b) -> a -> b
$ Int
push
)
)
[Int] -> WriterT Prompt (Reader OutputConfig) ()
addSpaceIfAnyBiggerThanZero [Int
pull, Int
push]
() -> WriterT Prompt (Reader OutputConfig) ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
addLocalBranchName :: ShellOutput
addLocalBranchName :: WriterT Prompt (Reader OutputConfig) ()
addLocalBranchName = do
GitRepoState
repoState <- WriterT Prompt (Reader OutputConfig) GitRepoState
forall (m :: * -> *). MonadReader OutputConfig m => m GitRepoState
askRepoState
Config
config <- WriterT Prompt (Reader OutputConfig) Config
forall (m :: * -> *). MonadReader OutputConfig m => m Config
askConfig
let localBranchName :: Prompt
localBranchName = GitRepoState -> Prompt
gitLocalBranch GitRepoState
repoState
let commitTag :: Prompt
commitTag = GitRepoState -> Prompt
gitCommitTag GitRepoState
repoState
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell (Config -> Prompt
confLocalBranchNamePrefix Config
config)
if (Prompt
localBranchName Prompt -> Prompt -> Bool
forall a. Eq a => a -> a -> Bool
/= Prompt
"")
then do
Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
tellStringInColor (Config -> Color
confLocalBranchColor Config
config) (Config -> ColorIntensity
confLocalBranchIntensity Config
config) (Prompt -> WriterT Prompt (Reader OutputConfig) ())
-> Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall a b. (a -> b) -> a -> b
$
Prompt
localBranchName
else do
if (Prompt
commitTag Prompt -> Prompt -> Bool
forall a. Eq a => a -> a -> Bool
/= Prompt
"")
then do
Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
tellStringInColor (Config -> Color
confLocalDetachedColor Config
config) (Config -> ColorIntensity
confLocalDetachedIntensity Config
config) (Prompt -> WriterT Prompt (Reader OutputConfig) ())
-> Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall a b. (a -> b) -> a -> b
$
(Config -> Prompt
confLocalDetachedPrefix Config
config) Prompt -> Prompt -> Prompt
forall a. [a] -> [a] -> [a]
++ Prompt
commitTag
else do
Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
tellStringInColor (Config -> Color
confLocalDetachedColor Config
config) (Config -> ColorIntensity
confLocalDetachedIntensity Config
config) (Prompt -> WriterT Prompt (Reader OutputConfig) ())
-> Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall a b. (a -> b) -> a -> b
$
(Config -> Prompt
confLocalDetachedPrefix Config
config) Prompt -> Prompt -> Prompt
forall a. [a] -> [a] -> [a]
++ (GitRepoState -> Prompt
gitCommitShortSHA GitRepoState
repoState)
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell (Config -> Prompt
confLocalBranchNameSuffix Config
config)
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell Prompt
" "
() -> WriterT Prompt (Reader OutputConfig) ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
addLocalCommits :: ShellOutput
addLocalCommits :: WriterT Prompt (Reader OutputConfig) ()
addLocalCommits = do
GitRepoState
repoState <- WriterT Prompt (Reader OutputConfig) GitRepoState
forall (m :: * -> *). MonadReader OutputConfig m => m GitRepoState
askRepoState
Config
config <- WriterT Prompt (Reader OutputConfig) Config
forall (m :: * -> *). MonadReader OutputConfig m => m Config
askConfig
let push :: Int
push = GitRepoState -> Int
gitCommitsToPush GitRepoState
repoState
let pull :: Int
pull = GitRepoState -> Int
gitCommitsToPull GitRepoState
repoState
if (Int
pull Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0) Bool -> Bool -> Bool
&& (Int
push Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0)
then do
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell (Prompt -> WriterT Prompt (Reader OutputConfig) ())
-> (Int -> Prompt)
-> Int
-> WriterT Prompt (Reader OutputConfig) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Prompt
forall a. Show a => a -> Prompt
show (Int -> WriterT Prompt (Reader OutputConfig) ())
-> Int -> WriterT Prompt (Reader OutputConfig) ()
forall a b. (a -> b) -> a -> b
$ Int
pull
Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
tellStringInColor
(Config -> Color
confLocalCommitsPushPullInfixColor Config
config)
(Config -> ColorIntensity
confLocalCommitsPushPullInfixIntensity Config
config)
(Config -> Prompt
confLocalCommitsPushPullInfix Config
config)
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell (Prompt -> WriterT Prompt (Reader OutputConfig) ())
-> (Int -> Prompt)
-> Int
-> WriterT Prompt (Reader OutputConfig) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Prompt
forall a. Show a => a -> Prompt
show (Int -> WriterT Prompt (Reader OutputConfig) ())
-> Int -> WriterT Prompt (Reader OutputConfig) ()
forall a b. (a -> b) -> a -> b
$ Int
push
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell Prompt
" "
else
if (Int
pull Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0)
then do
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell (Prompt -> WriterT Prompt (Reader OutputConfig) ())
-> (Int -> Prompt)
-> Int
-> WriterT Prompt (Reader OutputConfig) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Prompt
forall a. Show a => a -> Prompt
show (Int -> WriterT Prompt (Reader OutputConfig) ())
-> Int -> WriterT Prompt (Reader OutputConfig) ()
forall a b. (a -> b) -> a -> b
$ Int
pull
Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
tellStringInColor
(Config -> Color
confLocalCommitsPullSuffixColor Config
config)
(Config -> ColorIntensity
confLocalCommitsPullSuffixIntensity Config
config)
(Config -> Prompt
confLocalCommitsPullSuffix Config
config)
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell Prompt
" "
else
Bool
-> WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Int
push Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0) (WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ())
-> WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ()
forall a b. (a -> b) -> a -> b
$ do
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell (Prompt -> WriterT Prompt (Reader OutputConfig) ())
-> (Int -> Prompt)
-> Int
-> WriterT Prompt (Reader OutputConfig) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Prompt
forall a. Show a => a -> Prompt
show (Int -> WriterT Prompt (Reader OutputConfig) ())
-> Int -> WriterT Prompt (Reader OutputConfig) ()
forall a b. (a -> b) -> a -> b
$ Int
push
Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
tellStringInColor
(Config -> Color
confLocalCommitsPushSuffixColor Config
config)
(Config -> ColorIntensity
confLocalCommitsPushSuffixIntensity Config
config)
(Config -> Prompt
confLocalCommitsPushSuffix Config
config)
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell Prompt
" "
() -> WriterT Prompt (Reader OutputConfig) ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
addRepoState :: ShellOutput
addRepoState :: WriterT Prompt (Reader OutputConfig) ()
addRepoState = do
GitRepoState
repoState <- WriterT Prompt (Reader OutputConfig) GitRepoState
forall (m :: * -> *). MonadReader OutputConfig m => m GitRepoState
askRepoState
Config
config <- WriterT Prompt (Reader OutputConfig) Config
forall (m :: * -> *). MonadReader OutputConfig m => m Config
askConfig
let repoChanges :: GitLocalRepoChanges
repoChanges = GitRepoState -> GitLocalRepoChanges
gitLocalRepoChanges GitRepoState
repoState
let inda :: Int
inda = GitLocalRepoChanges -> Int
indexAdd GitLocalRepoChanges
repoChanges
let indd :: Int
indd = GitLocalRepoChanges -> Int
indexDel GitLocalRepoChanges
repoChanges
let indm :: Int
indm = GitLocalRepoChanges -> Int
indexMod GitLocalRepoChanges
repoChanges
let mv :: Int
mv = GitLocalRepoChanges -> Int
renamed GitLocalRepoChanges
repoChanges
Int
-> Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
addStateElem Int
inda
(Config -> Color
confChangeIndexAddSuffixColor Config
config)
(Config -> ColorIntensity
confChangeIndexAddSuffixIntensity Config
config)
(Config -> Prompt
confChangeIndexAddSuffix Config
config)
Int
-> Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
addStateElem Int
indd
(Config -> Color
confChangeIndexDelSuffixColor Config
config)
(Config -> ColorIntensity
confChangeIndexDelSuffixIntensity Config
config)
(Config -> Prompt
confChangeIndexDelSuffix Config
config)
Int
-> Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
addStateElem Int
indm
(Config -> Color
confChangeIndexModSuffixColor Config
config)
(Config -> ColorIntensity
confChangeIndexModSuffixIntensity Config
config)
(Config -> Prompt
confChangeIndexModSuffix Config
config)
Int
-> Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
addStateElem Int
mv
(Config -> Color
confChangeRenamedSuffixColor Config
config)
(Config -> ColorIntensity
confChangeRenamedSuffixIntensity Config
config)
(Config -> Prompt
confChangeRenamedSuffix Config
config)
[Int] -> WriterT Prompt (Reader OutputConfig) ()
addSpaceIfAnyBiggerThanZero [Int
inda, Int
indd, Int
indm, Int
mv]
let ld :: Int
ld = GitLocalRepoChanges -> Int
localDel GitLocalRepoChanges
repoChanges
let lm :: Int
lm = GitLocalRepoChanges -> Int
localMod GitLocalRepoChanges
repoChanges
Int
-> Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
addStateElem Int
ld
(Config -> Color
confChangeLocalDelSuffixColor Config
config)
(Config -> ColorIntensity
confChangeLocalDelSuffixIntensity Config
config)
(Config -> Prompt
confChangeLocalDelSuffix Config
config)
Int
-> Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
addStateElem Int
lm
(Config -> Color
confChangeLocalModSuffixColor Config
config)
(Config -> ColorIntensity
confChangeLocalModSuffixIntensity Config
config)
(Config -> Prompt
confChangeLocalModSuffix Config
config)
[Int] -> WriterT Prompt (Reader OutputConfig) ()
addSpaceIfAnyBiggerThanZero [Int
ld, Int
lm]
let la :: Int
la = GitLocalRepoChanges -> Int
localAdd GitLocalRepoChanges
repoChanges
Int
-> Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
addStateElem Int
la
(Config -> Color
confChangeLocalAddSuffixColor Config
config)
(Config -> ColorIntensity
confChangeLocalAddSuffixIntensity Config
config)
(Config -> Prompt
confChangeLocalAddSuffix Config
config)
[Int] -> WriterT Prompt (Reader OutputConfig) ()
addSpaceIfAnyBiggerThanZero [Int
la]
let co :: Int
co = GitLocalRepoChanges -> Int
conflict GitLocalRepoChanges
repoChanges
Int
-> Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
addStateElem Int
co
(Config -> Color
confChangeConflictedSuffixColor Config
config)
(Config -> ColorIntensity
confChangeConflictedSuffixIntensity Config
config)
(Config -> Prompt
confChangeConflictedSuffix Config
config)
[Int] -> WriterT Prompt (Reader OutputConfig) ()
addSpaceIfAnyBiggerThanZero [Int
co]
() -> WriterT Prompt (Reader OutputConfig) ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
addSpaceIfAnyBiggerThanZero :: [Int] -> ShellOutput
addSpaceIfAnyBiggerThanZero :: [Int] -> WriterT Prompt (Reader OutputConfig) ()
addSpaceIfAnyBiggerThanZero [Int]
list =
Bool
-> WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when ((Int -> Bool) -> [Int] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>Int
0) [Int]
list) (WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ())
-> WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ()
forall a b. (a -> b) -> a -> b
$ Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell Prompt
" "
addStateElem :: Int
-> Color
-> ColorIntensity
-> String
-> ShellOutput
addStateElem :: Int
-> Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
addStateElem Int
stateElem Color
color ColorIntensity
intensity Prompt
letter =
Bool
-> WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Int
stateElem Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0) (WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ())
-> WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ()
forall a b. (a -> b) -> a -> b
$ Int
-> Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
addNumStateElem Int
stateElem Color
color ColorIntensity
intensity Prompt
letter
addNumStateElem :: Int
-> Color
-> ColorIntensity
-> String
-> ShellOutput
addNumStateElem :: Int
-> Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
addNumStateElem Int
num Color
color ColorIntensity
intensity Prompt
letter = do
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell (Prompt -> WriterT Prompt (Reader OutputConfig) ())
-> (Int -> Prompt)
-> Int
-> WriterT Prompt (Reader OutputConfig) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Prompt
forall a. Show a => a -> Prompt
show (Int -> WriterT Prompt (Reader OutputConfig) ())
-> Int -> WriterT Prompt (Reader OutputConfig) ()
forall a b. (a -> b) -> a -> b
$ Int
num
Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
tellStringInColor Color
color ColorIntensity
intensity Prompt
letter
() -> WriterT Prompt (Reader OutputConfig) ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
addStashes :: ShellOutput
addStashes :: WriterT Prompt (Reader OutputConfig) ()
addStashes = do
GitRepoState
repoState <- WriterT Prompt (Reader OutputConfig) GitRepoState
forall (m :: * -> *). MonadReader OutputConfig m => m GitRepoState
askRepoState
Config
config <- WriterT Prompt (Reader OutputConfig) Config
forall (m :: * -> *). MonadReader OutputConfig m => m Config
askConfig
let stashCount :: Int
stashCount = GitRepoState -> Int
gitStashCount GitRepoState
repoState
Bool
-> WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Int
stashCount Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
/= Int
0) (WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ())
-> WriterT Prompt (Reader OutputConfig) ()
-> WriterT Prompt (Reader OutputConfig) ()
forall a b. (a -> b) -> a -> b
$ do
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell (Prompt -> WriterT Prompt (Reader OutputConfig) ())
-> (Int -> Prompt)
-> Int
-> WriterT Prompt (Reader OutputConfig) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Prompt
forall a. Show a => a -> Prompt
show (Int -> WriterT Prompt (Reader OutputConfig) ())
-> Int -> WriterT Prompt (Reader OutputConfig) ()
forall a b. (a -> b) -> a -> b
$ Int
stashCount
Color
-> ColorIntensity
-> Prompt
-> WriterT Prompt (Reader OutputConfig) ()
tellStringInColor
(Config -> Color
confStashSuffixColor Config
config)
(Config -> ColorIntensity
confStashSuffixIntensity Config
config)
(Config -> Prompt
confStashSuffix Config
config)
Prompt -> WriterT Prompt (Reader OutputConfig) ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell Prompt
" "