Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Revision history for igitt

## 0.2.2.0 -- 2025-07-08

* Commit message input asks for a single-line input instead of multiline

## 0.2.1.0 -- 2025-07-03

* Add --version argument.
Expand Down
44 changes: 2 additions & 42 deletions app/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ module Prelude
where

import Control.Applicative ((<|>))
import Control.Lens (Iso', iso, over, view)
import Control.Monad.Extra (whenM)
import Control.Monad.Logger (LogLevel)
import Data.Either.Extra (eitherToMaybe)
import Data.Functor
import Data.Functor.Identity
import Data.List qualified as List
import Data.List.Extra ((!?))
import Data.List.NonEmpty (NonEmpty (..))
import Data.Maybe (fromMaybe, mapMaybe)
Expand All @@ -51,14 +49,12 @@ import Options.Applicative
, strArgument
, strOption
)
import Prettyprinter (annotate, pretty)
import System.Console.ANSI
import System.Exit (ExitCode (..), exitFailure, exitWith)
import System.IO (stderr)
import System.Process qualified as Process
import System.Terminal (MonadColorPrinter (..), bold)
import System.Terminal.Widgets.Buttons
import System.Terminal.Widgets.Common (Widget (..), runWidgetIO)
import System.Terminal.Widgets.Common (runWidgetIO)
import System.Terminal.Widgets.TextInput
import Text.Read (readMaybe)
import "base" Prelude hiding (unzip)
Expand Down Expand Up @@ -128,44 +124,8 @@ textInput = textInputOpts False True
multilineTextInput :: Text -> Text -> IO Text
multilineTextInput = textInputOpts True False

newtype CommitMessage = CommitMessage TextInput

commitMessageIso :: Iso' CommitMessage TextInput
commitMessageIso = iso (\(CommitMessage t) -> t) CommitMessage

instance Widget CommitMessage where
cursor = commitMessageIso . cursor
handleEvent = over commitMessageIso . handleEvent
submitEvent = submitEvent . view commitMessageIso
valid = valid . view commitMessageIso
lineCount = lineCount . view commitMessageIso
toDoc (view commitMessageIso -> TextInput{..}) =
mconcat
. List.intersperse "\n"
. padLines
. Text.split (== '\n')
. valueTransform
. RopeZipper.toText
$ value
where
padLines (x : xs) =
(pretty prompt <> (annotate (foreground yellow) . annotate bold . pretty) x)
: (pretty . (Text.replicate (Text.length prompt) " " <>) <$> xs)
padLines [] = [pretty prompt]

commitMessageInput :: Text -> IO Text
commitMessageInput (RopeZipper.fromText -> value) = do
CommitMessage t <-
runWidgetIO $
CommitMessage
TextInput
{ valueTransform = id
, prompt = "Commit message: "
, multiline = True
, required = True
, value
}
pure . RopeZipper.toText $ t.value
commitMessageInput = textInput "Commit message: "

buttons :: (Eq a, Show a) => Text -> [(a, Char)] -> Int -> (a -> Text) -> IO a
buttons prompt values selected buttonText = do
Expand Down
5 changes: 1 addition & 4 deletions igitt.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: igitt
version: 0.2.1.0
version: 0.2.2.0
synopsis: Git wrapper to work with numbered branches
homepage: https://github.com/ners/igitt/blob/master/README.md
license: Apache-2.0
Expand Down Expand Up @@ -59,13 +59,10 @@ executable igitt
ansi-terminal,
base >= 4.16 && < 5,
extra,
lens,
monad-logger,
optparse-applicative,
prettyprinter,
process,
regex-tdfa,
terminal,
terminal-widgets,
text,
text-rope-zipper,
Expand Down