cli: make register-match a builtin command
This commit is contained in:
parent
bf99c74198
commit
89f694707b
@ -27,6 +27,7 @@ module Hledger.Cli.Commands (
|
|||||||
,module Hledger.Cli.Commands.Print
|
,module Hledger.Cli.Commands.Print
|
||||||
,module Hledger.Cli.Commands.Printunique
|
,module Hledger.Cli.Commands.Printunique
|
||||||
,module Hledger.Cli.Commands.Register
|
,module Hledger.Cli.Commands.Register
|
||||||
|
,module Hledger.Cli.Commands.Registermatch
|
||||||
,module Hledger.Cli.Commands.Stats
|
,module Hledger.Cli.Commands.Stats
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
@ -61,6 +62,7 @@ import Hledger.Cli.Commands.Prices
|
|||||||
import Hledger.Cli.Commands.Print
|
import Hledger.Cli.Commands.Print
|
||||||
import Hledger.Cli.Commands.Printunique
|
import Hledger.Cli.Commands.Printunique
|
||||||
import Hledger.Cli.Commands.Register
|
import Hledger.Cli.Commands.Register
|
||||||
|
import Hledger.Cli.Commands.Registermatch
|
||||||
import Hledger.Cli.Commands.Stats
|
import Hledger.Cli.Commands.Stats
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,46 +1,35 @@
|
|||||||
#!/usr/bin/env stack
|
|
||||||
{- stack runghc --verbosity info
|
|
||||||
--package hledger-lib
|
|
||||||
--package hledger
|
|
||||||
--package here
|
|
||||||
--package text
|
|
||||||
-}
|
|
||||||
|
|
||||||
{-# OPTIONS_GHC -Wno-missing-signatures -Wno-name-shadowing #-}
|
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
{-# LANGUAGE QuasiQuotes #-}
|
{-# LANGUAGE QuasiQuotes #-}
|
||||||
|
|
||||||
|
module Hledger.Cli.Commands.Registermatch (
|
||||||
|
registermatchmode
|
||||||
|
,registermatch
|
||||||
|
)
|
||||||
|
where
|
||||||
|
|
||||||
import Data.Char (toUpper)
|
import Data.Char (toUpper)
|
||||||
import Data.List
|
import Data.List
|
||||||
import Data.String.Here
|
import Data.String.Here
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
-- import System.Console.CmdArgs
|
|
||||||
-- import System.Console.CmdArgs.Explicit
|
|
||||||
|
|
||||||
import Hledger
|
import Hledger
|
||||||
import Hledger.Cli.CliOptions
|
import Hledger.Cli.CliOptions
|
||||||
import Hledger.Cli ( withJournalDo, postingsReportAsText )
|
import Hledger.Cli.Commands.Register
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
registermatchmode = hledgerCommandMode
|
||||||
cmdmode = hledgerCommandMode
|
|
||||||
[here| register-match
|
[here| register-match
|
||||||
A helper for ledger-autosync. This prints the one posting whose transaction
|
Print the one posting whose transaction description is closest to DESC,
|
||||||
description is closest to DESC, in the style of the register command.
|
in the style of the register command.
|
||||||
If there are multiple equally good matches, it shows the most recent.
|
If there are multiple equally good matches, it shows the most recent.
|
||||||
Query options (options, not arguments) can be used to restrict the search space.
|
Query options (options, not arguments) can be used to restrict the search space.
|
||||||
|
Helps ledger-autosync detect already-seen transactions when importing.
|
||||||
|]
|
|]
|
||||||
[]
|
[]
|
||||||
[generalflagsgroup1]
|
[generalflagsgroup1]
|
||||||
[]
|
[]
|
||||||
([], Nothing)
|
([], Nothing)
|
||||||
------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
main = do
|
registermatch :: CliOpts -> Journal -> IO ()
|
||||||
opts <- getHledgerCliOpts cmdmode
|
registermatch opts@CliOpts{rawopts_=rawopts,reportopts_=ropts} j = do
|
||||||
withJournalDo opts match
|
|
||||||
|
|
||||||
match :: CliOpts -> Journal -> IO ()
|
|
||||||
match opts@CliOpts{rawopts_=rawopts,reportopts_=ropts} j = do
|
|
||||||
let args' = listofstringopt "args" rawopts
|
let args' = listofstringopt "args" rawopts
|
||||||
case args' of
|
case args' of
|
||||||
[desc] -> do
|
[desc] -> do
|
||||||
@ -89,11 +89,6 @@ is an old pie chart generator, in need of some love.
|
|||||||
[hledger-check.hs](https://github.com/simonmichael/hledger/blob/master/bin/hledger-check.hs)
|
[hledger-check.hs](https://github.com/simonmichael/hledger/blob/master/bin/hledger-check.hs)
|
||||||
checks more powerful account balance assertions.
|
checks more powerful account balance assertions.
|
||||||
|
|
||||||
### register-match
|
|
||||||
|
|
||||||
[hledger-register-match.hs](https://github.com/simonmichael/hledger/blob/master/bin/hledger-register-match.hs#L23)
|
|
||||||
helps ledger-autosync detect already-seen transactions when importing.
|
|
||||||
|
|
||||||
### rewrite
|
### rewrite
|
||||||
|
|
||||||
[hledger-rewrite.hs](https://github.com/simonmichael/hledger/blob/master/bin/hledger-rewrite.hs#L28)
|
[hledger-rewrite.hs](https://github.com/simonmichael/hledger/blob/master/bin/hledger-rewrite.hs#L28)
|
||||||
|
|||||||
@ -680,6 +680,11 @@ The register command also supports the
|
|||||||
`-o/--output-file` and `-O/--output-format` options for controlling
|
`-o/--output-file` and `-O/--output-format` options for controlling
|
||||||
[output destination](#output-destination) and [CSV output](#csv-output).
|
[output destination](#output-destination) and [CSV output](#csv-output).
|
||||||
|
|
||||||
|
## register-match
|
||||||
|
Print the one posting whose transaction description is closest to DESC,
|
||||||
|
in the style of the register command.
|
||||||
|
Helps ledger-autosync detect already-seen transactions when importing.
|
||||||
|
|
||||||
## stats
|
## stats
|
||||||
Show some journal statistics.
|
Show some journal statistics.
|
||||||
|
|
||||||
|
|||||||
@ -136,7 +136,9 @@ library
|
|||||||
Hledger.Cli.Commands.Incomestatement
|
Hledger.Cli.Commands.Incomestatement
|
||||||
Hledger.Cli.Commands.Prices
|
Hledger.Cli.Commands.Prices
|
||||||
Hledger.Cli.Commands.Print
|
Hledger.Cli.Commands.Print
|
||||||
|
Hledger.Cli.Commands.Printunique
|
||||||
Hledger.Cli.Commands.Register
|
Hledger.Cli.Commands.Register
|
||||||
|
Hledger.Cli.Commands.Registermatch
|
||||||
Hledger.Cli.Commands.Stats
|
Hledger.Cli.Commands.Stats
|
||||||
Hledger.Cli.CompoundBalanceCommand
|
Hledger.Cli.CompoundBalanceCommand
|
||||||
Text.Tabular.AsciiWide
|
Text.Tabular.AsciiWide
|
||||||
|
|||||||
@ -119,6 +119,7 @@ library:
|
|||||||
- Hledger.Cli.Commands.Print
|
- Hledger.Cli.Commands.Print
|
||||||
- Hledger.Cli.Commands.Printunique
|
- Hledger.Cli.Commands.Printunique
|
||||||
- Hledger.Cli.Commands.Register
|
- Hledger.Cli.Commands.Register
|
||||||
|
- Hledger.Cli.Commands.Registermatch
|
||||||
- Hledger.Cli.Commands.Stats
|
- Hledger.Cli.Commands.Stats
|
||||||
- Hledger.Cli.CompoundBalanceCommand
|
- Hledger.Cli.CompoundBalanceCommand
|
||||||
- Text.Tabular.AsciiWide
|
- Text.Tabular.AsciiWide
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user