packages feed

hledger-iadd 1.1.1 → 1.1.2

raw patch · 9 files changed

+87/−44 lines, 9 filesdep ~brickdep ~hledger-libPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: brick, hledger-lib

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -1,3 +1,11 @@+# 1.1.2++ - Respect ${LEDGER_FILE} environment variable+ - Add --version command+ - Bump brick dependency to 0.15.2+ - Bump hledger-lib dependency to 1.1+ - Bind C-u to 'delete to beginning of line'+ # 1.1.1   - bugfix: Show cursor in empty entry widget
README.md view
@@ -19,12 +19,45 @@  - Configurable format for date input. Instead of `y/m/d` it is also    possible to use other formats like the german `d.m.y`. +Also see the user guide under [Usage](#usage).+ ## Installation-### stack+### Latest release+#### stack -The easiest method would be [stack]: Install the [stack] program, `cd`-to `hledger-iadd`s source directory and type:+The easiest method would be [stack]: Install the [stack] program and+type: +    stack install --resolver=nightly hledger-iadd++This downloads and builds `hledger-iadd` and all it's Haskell+dependencies. After that, it copys the resulting binary to+`~/.local/bin`. See `stack --help` for more options. You may get asked+to install the GHC Haskell compiler locally. To do that, type `stack+setup`.++#### cabal++First, install the GHC Haskell compiler and the `cabal install`,+`alex` and `happy` build tools, possibly from your distribution or the+[haskell platform]. Type++    cabal install --bindir ~/bin hledger-iadd++to install the binary in `~/bin`.++### Development version++To install the development version, clone the git repository first:++    git clone https://github.com/hpdeifel/hledger-iadd.git+	cd hledger-iadd++#### stack++The easiest method would be [stack]: Install the [stack] program and+type:+     stack install  To build and install all Haskell dependencies locally and install@@ -32,7 +65,7 @@ You may get asked to install the GHC Haskell compiler locally. To do that, type `stack setup`. -### Cabal+#### Cabal  First, install the GHC Haskell compiler and the `cabal install`, `alex` and `happy` build tools, possibly from your distribution or the
hledger-iadd.cabal view
@@ -1,5 +1,5 @@ name:                hledger-iadd-version:             1.1.1+version:             1.1.2 synopsis:            A terminal UI as drop-in replacement for hledger add description:         This is a terminal UI as drop-in replacement for hledger add.                      .@@ -8,11 +8,14 @@                        * Interactive as-you-type completion for                          account names and descriptions with optional                          fuzzy matching.+                     .                        * Integrated calculator: Amounts can be written                          as simple sums with real-time feedback on the                          result.+                     .                        * All actions while entering a transaction can                          be undone+                     .                        * Configurable format for date input. Instead                          of @y\/m\/d@ it is also possible to use other                          formats like the german @d.m.y@.@@ -51,8 +54,8 @@                      , Brick.Widgets.WrappedText   default-language:    Haskell2010   build-depends:       base >= 4.8 && < 5-                     , hledger-lib >= 1.0 && < 1.1-                     , brick >= 0.14 && < 0.16+                     , hledger-lib >= 1.0 && < 1.2+                     , brick >= 0.15.2 && < 0.16                      , vty >= 5.4                      , text                      , microlens@@ -68,6 +71,7 @@                      , xdg-basedir                      , unordered-containers                      , free >= 4.12.4+  ghc-options:         -Wall -fdefer-typed-holes -fno-warn-name-shadowing  executable hledger-iadd   hs-source-dirs:      src/main@@ -75,8 +79,8 @@   default-language:    Haskell2010   build-depends:       base >= 4.8 && < 5                      , hledger-iadd-                     , hledger-lib >= 1.0 && < 1.1-                     , brick >= 0.14 && < 0.16+                     , hledger-lib >= 1.0 && < 1.2+                     , brick >= 0.15.2 && < 0.16                      , vty >= 5.4                      , text                      , microlens@@ -91,8 +95,7 @@                      , unordered-containers                      , free >= 4.12.4                      , megaparsec >= 5.0 && <5.2--  ghc-options:         -threaded+  ghc-options:         -threaded -Wall -fdefer-typed-holes -fno-warn-name-shadowing  test-suite spec   type:               exitcode-stdio-1.0@@ -104,7 +107,7 @@   default-language:   Haskell2010   build-depends:      base >= 4.8 && < 5                     , hledger-iadd-                    , hledger-lib >= 1.0 && < 1.1+                    , hledger-lib >= 1.0 && < 1.2                     , text                     , transformers >= 0.3                     , time >= 1.5@@ -114,4 +117,4 @@                     , text-format                     , free >= 4.12.4                     , megaparsec >= 5.0 && <5.2-  ghc-options:        -threaded -Wall+  ghc-options:        -threaded -Wall -fdefer-typed-holes -fno-warn-name-shadowing
src/AmountParser.hs view
@@ -1,7 +1,6 @@ module AmountParser (parseAmount) where  import           Data.Text (Text)-import qualified Data.Text as T import qualified Hledger as HL import           Data.Functor.Identity import           Control.Monad.Trans.State.Strict
src/ConfigParser.hs view
@@ -45,20 +45,15 @@  import           Control.Applicative import           Control.Applicative.Free-import           Control.Arrow import           Control.Monad-import           Data.Char import           Data.Functor.Identity import           Data.Monoid-import           Data.String import           Data.Text (Text) import qualified Data.Text as T import qualified Data.Text.IO as T import qualified Data.Set as S import qualified Text.Megaparsec as P import           Text.Megaparsec hiding ((<|>), many, option, optional)-import           Text.Megaparsec.Char-import           Text.Megaparsec.Error import           Text.Megaparsec.Text  -- | Parse a config file from a 'Text'.@@ -191,8 +186,6 @@            "in " ++ T.unpack (optType opt) ++ " argument for option " ++ T.unpack (assignmentKey ass)          Right res -> Right $ fmap ($ res) rest   | otherwise = fmap (Ap opt) $ parseOption rest ass--  where testParse = Nothing  -- Low level assignment parser 
src/View.hs view
@@ -31,7 +31,7 @@   "Account " ++ show (numPostings trans + 1) viewQuestion (AmountQuestion _ trans) = str $   "Amount " ++ show (numPostings trans + 1)-viewQuestion (FinalQuestion trans) = txt $+viewQuestion (FinalQuestion _) = txt $   "Add this transaction to the journal? Y/n"  viewContext :: (Ord n, Show n) => List n Text -> Widget n
src/main/Main.hs view
@@ -31,6 +31,7 @@ import qualified Options.Applicative as OA import           Options.Applicative hiding (str, option) import           System.Directory+import           System.Environment import           System.Environment.XDG.BaseDir import           System.Exit import           System.IO@@ -43,6 +44,9 @@ import           Model import           View +import           Data.Version (showVersion)+import qualified Paths_hledger_iadd as Paths+ data AppState = AppState   { asEditor :: Editor Text Name   , asStep :: Step@@ -150,7 +154,6 @@     EvKey KEnter [] -> liftIO (doNextStep True as) >>= continue     EvKey (KFun 1) [] -> continue as { asDialog = myHelpDialog }     EvKey (KChar '?') [MMeta] -> continue as { asDialog = myHelpDialog, asMessage = "Help" }-    EvKey (KChar 'u') [MCtrl] -> continue as { asEditor = clearEdit (asEditor as) }     _ -> (AppState <$> handleEditorEvent ev (asEditor as)                    <*> return (asStep as)                    <*> return (asJournal as)@@ -286,7 +289,7 @@    mempty = CommonOptions Nothing Nothing Nothing -optNatTrans :: Functor f => (forall a. f a -> g a) -> CommonOptions f -> CommonOptions g+optNatTrans :: (forall a. f a -> g a) -> CommonOptions f -> CommonOptions g optNatTrans nat opts = CommonOptions   { optLedgerFile = nat $ optLedgerFile opts   , optDateFormat = nat $ optDateFormat opts@@ -300,6 +303,7 @@ data CmdLineOptions = CmdLineOptions   { cmdCommon :: CommonOptions Maybe   , cmdDumpConfig :: Bool+  , cmdVersion :: Bool   }  data ConfOptions = ConfOptions { confCommon :: CommonOptions Maybe }@@ -390,10 +394,16 @@         ( long "dump-default-config"        <> help "Print an example configuration file to stdout and exit"         )+  <*> switch+        ( long "version"+       <> help "Print version number and exit"+        ) ------------------------------------------------------------------------------------ main---------------------------------------------------------------------------------+parseEnvVariables :: IO (CommonOptions Maybe)+parseEnvVariables = do+  maybeFilePath <- lookupEnv "LEDGER_FILE"+  return mempty+    { optLedgerFile = maybeFilePath }  main :: IO () main = do@@ -404,6 +414,10 @@   cmdOpts <- execParser $ info (helper <*> cmdOptionParser) $                fullDesc <> header "A terminal UI as drop-in replacement for hledger add." +  when (cmdVersion cmdOpts) $ do+    putStrLn $ "This is hledger-iadd version " <> showVersion Paths.version+    exitSuccess+   when (cmdDumpConfig cmdOpts) $ do     T.putStrLn $ "# Write this to " <> T.pack path <> "\n"     T.putStrLn (parserExample $ confParser defOpts)@@ -411,8 +425,12 @@    confOpts <- parseConfigFile -  let opts = optFromJust defOpts $ cmdCommon cmdOpts <> confCommon confOpts+  envOpts <- parseEnvVariables +  -- The order of precedence here is:+  -- arguments > environment > config file+  let opts = optFromJust defOpts $ cmdCommon cmdOpts <> envOpts <> confCommon confOpts+   date <- case parseDateFormat (T.pack $ runIdentity $ optDateFormat opts) of     Left err -> do       hPutStr stderr "Could not parse date format: "@@ -426,7 +444,7 @@   runExceptT (HL.parseAndFinaliseJournal HL.journalp True path journalContents) >>= \case     Left err -> hPutStrLn stderr err >> exitFailure     Right journal -> do-      let edit = editor EditorName (nonEmptyTxt . T.concat) (Just 1) ""+      let edit = editor EditorName (txt . T.concat) (Just 1) ""        sugg <- suggest journal date DateQuestion @@ -448,12 +466,3 @@  ctxList :: V.Vector e -> List Name e ctxList v = (if V.null v then id else listMoveTo 0) $ list ListName v 1---- | Workaround for bug in brick's edit widget------ Since brick version 0.15, an empty edit widget wouldn't show a cursor, so--- this artificially adds a space to empty input text.-nonEmptyTxt :: Text -> Widget n-nonEmptyTxt input-  | T.null input = txt " "-  | otherwise    = txt input
tests/ConfigParserSpec.hs view
@@ -1,11 +1,11 @@ {-# LANGUAGE OverloadedStrings #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+ module ConfigParserSpec (spec) where  import           Test.Hspec import           Test.QuickCheck -import           Control.Arrow-import           Data.Char import           Data.Text (Text) import qualified Data.Text as T @@ -239,9 +239,6 @@  isLeft :: Either a b -> Bool isLeft = either (const True) (const False)--isAsciiAlnum :: Char -> Bool-isAsciiAlnum = uncurry (&&) . (isAscii &&& isAlphaNum)  instance Arbitrary TestData where   arbitrary = TestData <$> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary
tests/DateParserSpec.hs view
@@ -1,4 +1,5 @@- {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE OverloadedStrings #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}  module DateParserSpec (spec) where