feat:setup: command skeleton
This commit is contained in:
parent
29bca306ee
commit
cff831c3c0
@ -49,6 +49,7 @@ module Hledger.Cli.Commands (
|
|||||||
,module Hledger.Cli.Commands.Register
|
,module Hledger.Cli.Commands.Register
|
||||||
,module Hledger.Cli.Commands.Rewrite
|
,module Hledger.Cli.Commands.Rewrite
|
||||||
,module Hledger.Cli.Commands.Run
|
,module Hledger.Cli.Commands.Run
|
||||||
|
,module Hledger.Cli.Commands.Setup
|
||||||
,module Hledger.Cli.Commands.Stats
|
,module Hledger.Cli.Commands.Stats
|
||||||
,module Hledger.Cli.Commands.Tags
|
,module Hledger.Cli.Commands.Tags
|
||||||
)
|
)
|
||||||
@ -99,6 +100,7 @@ import Hledger.Cli.Commands.Register
|
|||||||
import Hledger.Cli.Commands.Rewrite
|
import Hledger.Cli.Commands.Rewrite
|
||||||
import Hledger.Cli.Commands.Roi
|
import Hledger.Cli.Commands.Roi
|
||||||
import Hledger.Cli.Commands.Run
|
import Hledger.Cli.Commands.Run
|
||||||
|
import Hledger.Cli.Commands.Setup
|
||||||
import Hledger.Cli.Commands.Stats
|
import Hledger.Cli.Commands.Stats
|
||||||
import Hledger.Cli.Commands.Tags
|
import Hledger.Cli.Commands.Tags
|
||||||
import Hledger.Cli.Utils (tests_Cli_Utils)
|
import Hledger.Cli.Utils (tests_Cli_Utils)
|
||||||
@ -138,6 +140,7 @@ builtinCommands = [
|
|||||||
,(roimode , roi)
|
,(roimode , roi)
|
||||||
,(runmode , runOrReplStub)
|
,(runmode , runOrReplStub)
|
||||||
,(replmode , runOrReplStub)
|
,(replmode , runOrReplStub)
|
||||||
|
,(setupmode , setup)
|
||||||
,(statsmode , stats)
|
,(statsmode , stats)
|
||||||
,(tagsmode , tags)
|
,(tagsmode , tags)
|
||||||
,(testmode , testcmd)
|
,(testmode , testcmd)
|
||||||
@ -292,6 +295,7 @@ commandsList progversion othercmds =
|
|||||||
," diff compare an account's transactions in two journals"
|
," diff compare an account's transactions in two journals"
|
||||||
,"+git save or view journal file history simply in git" -- hledger-git
|
,"+git save or view journal file history simply in git" -- hledger-git
|
||||||
,"+pijul save or view journal file history simply in pijul" -- hledger-pijul
|
,"+pijul save or view journal file history simply in pijul" -- hledger-pijul
|
||||||
|
," setup check and help set up various installation things"
|
||||||
," test run some self tests"
|
," test run some self tests"
|
||||||
,""
|
,""
|
||||||
-----------------------------------------80-------------------------------------
|
-----------------------------------------80-------------------------------------
|
||||||
|
|||||||
64
hledger/Hledger/Cli/Commands/Setup.hs
Normal file
64
hledger/Hledger/Cli/Commands/Setup.hs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
{-|
|
||||||
|
|
||||||
|
Check and help set up various installation things.
|
||||||
|
|
||||||
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
{-# LANGUAGE NamedFieldPuns #-}
|
||||||
|
{-# LANGUAGE RecordWildCards #-}
|
||||||
|
|
||||||
|
module Hledger.Cli.Commands.Setup (
|
||||||
|
setupmode
|
||||||
|
,setup
|
||||||
|
)
|
||||||
|
where
|
||||||
|
|
||||||
|
-- import Data.Default (def)
|
||||||
|
-- import System.FilePath (takeFileName)
|
||||||
|
-- import Data.List (intercalate, nub, sortOn)
|
||||||
|
-- import Data.List.Extra (nubSort)
|
||||||
|
-- import qualified Data.Map as Map
|
||||||
|
-- import Data.Maybe (fromMaybe)
|
||||||
|
-- import Data.HashSet (size, fromList)
|
||||||
|
-- import qualified Data.Text as T
|
||||||
|
-- import qualified Data.Text.Lazy as TL
|
||||||
|
-- import qualified Data.Text.Lazy.Builder as TB
|
||||||
|
-- import Data.Time.Calendar (Day, addDays, diffDays)
|
||||||
|
-- import Data.Time.Clock.POSIX (getPOSIXTime)
|
||||||
|
-- import GHC.Stats
|
||||||
|
-- -- import System.Console.CmdArgs.Explicit hiding (Group)
|
||||||
|
-- import System.Mem (performMajorGC)
|
||||||
|
-- import Text.Printf (printf)
|
||||||
|
-- import Text.Tabular.AsciiWide
|
||||||
|
|
||||||
|
import Hledger
|
||||||
|
import Hledger.Cli.CliOptions
|
||||||
|
-- import Hledger.Cli.Utils (writeOutputLazyText)
|
||||||
|
|
||||||
|
|
||||||
|
setupmode = hledgerCommandMode
|
||||||
|
$(embedFileRelative "Hledger/Cli/Commands/Setup.txt")
|
||||||
|
[]
|
||||||
|
cligeneralflagsgroups1
|
||||||
|
hiddenflags
|
||||||
|
([], Just $ argsFlag "[QUERY]")
|
||||||
|
|
||||||
|
-- like Register.summarisePostings
|
||||||
|
-- | Print various statistics for the journal.
|
||||||
|
setup :: CliOpts -> Journal -> IO ()
|
||||||
|
setup _opts@CliOpts{rawopts_=_rawopts, reportspec_=_rspec} _j = do
|
||||||
|
print "setup"
|
||||||
|
|
||||||
|
|
||||||
|
-- let today = _rsDay rspec
|
||||||
|
-- verbose = boolopt "verbose" rawopts
|
||||||
|
-- q = _rsQuery rspec
|
||||||
|
-- l = ledgerFromJournal q j
|
||||||
|
-- intervalspans = snd $ reportSpanBothDates j rspec
|
||||||
|
-- ismultiperiod = length intervalspans > 1
|
||||||
|
-- (ls, txncounts) = unzip $ map (showLedgerStats verbose l today) intervalspans
|
||||||
|
-- numtxns = sum txncounts
|
||||||
|
-- txt = (if ismultiperiod then id else TL.init) $ TB.toLazyText $ unlinesB ls
|
||||||
|
-- writeOutputLazyText opts txt
|
||||||
9
hledger/Hledger/Cli/Commands/Setup.md
Normal file
9
hledger/Hledger/Cli/Commands/Setup.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
## setup
|
||||||
|
|
||||||
|
Check and help set up various installation things.
|
||||||
|
|
||||||
|
```flags
|
||||||
|
Flags:
|
||||||
|
no command-specific flags
|
||||||
|
```
|
||||||
|
|
||||||
6
hledger/Hledger/Cli/Commands/Setup.txt
Normal file
6
hledger/Hledger/Cli/Commands/Setup.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
setup
|
||||||
|
|
||||||
|
Check and help set up various installation things.
|
||||||
|
|
||||||
|
Flags:
|
||||||
|
no command-specific flags
|
||||||
@ -70,6 +70,7 @@ _command_({{Rewrite}})
|
|||||||
|
|
||||||
_command_({{Check}})
|
_command_({{Check}})
|
||||||
_command_({{Diff}})
|
_command_({{Diff}})
|
||||||
|
_command_({{Setup}})
|
||||||
_command_({{Test}})
|
_command_({{Test}})
|
||||||
|
|
||||||
}})m4_dnl
|
}})m4_dnl
|
||||||
|
|||||||
@ -87,6 +87,7 @@ extra-source-files:
|
|||||||
Hledger/Cli/Commands/Repl.txt
|
Hledger/Cli/Commands/Repl.txt
|
||||||
Hledger/Cli/Commands/Roi.txt
|
Hledger/Cli/Commands/Roi.txt
|
||||||
Hledger/Cli/Commands/Run.txt
|
Hledger/Cli/Commands/Run.txt
|
||||||
|
Hledger/Cli/Commands/Setup.txt
|
||||||
Hledger/Cli/Commands/Stats.txt
|
Hledger/Cli/Commands/Stats.txt
|
||||||
Hledger/Cli/Commands/Tags.txt
|
Hledger/Cli/Commands/Tags.txt
|
||||||
Hledger/Cli/Commands/Test.txt
|
Hledger/Cli/Commands/Test.txt
|
||||||
@ -139,6 +140,7 @@ library
|
|||||||
Hledger.Cli.Commands.Rewrite
|
Hledger.Cli.Commands.Rewrite
|
||||||
Hledger.Cli.Commands.Roi
|
Hledger.Cli.Commands.Roi
|
||||||
Hledger.Cli.Commands.Run
|
Hledger.Cli.Commands.Run
|
||||||
|
Hledger.Cli.Commands.Setup
|
||||||
Hledger.Cli.Commands.Stats
|
Hledger.Cli.Commands.Stats
|
||||||
Hledger.Cli.Commands.Tags
|
Hledger.Cli.Commands.Tags
|
||||||
Hledger.Cli.CompoundBalanceCommand
|
Hledger.Cli.CompoundBalanceCommand
|
||||||
|
|||||||
@ -702,6 +702,7 @@ Here are those commands and the formats currently supported:
|
|||||||
| prices | | | | | |
|
| prices | | | | | |
|
||||||
| rewrite | | | | | |
|
| rewrite | | | | | |
|
||||||
| roi | | | | | |
|
| roi | | | | | |
|
||||||
|
| setup | | | | | |
|
||||||
| stats | | | | | |
|
| stats | | | | | |
|
||||||
| stockquotes | | | | | |
|
| stockquotes | | | | | |
|
||||||
| tags | | | | | |
|
| tags | | | | | |
|
||||||
@ -6514,6 +6515,7 @@ If you have installed more [add-on commands](../scripts.md), they also will be l
|
|||||||
|
|
||||||
- [check](#check) - check for various kinds of error in the data
|
- [check](#check) - check for various kinds of error in the data
|
||||||
- [diff](#diff) - compare account transactions in two journal files
|
- [diff](#diff) - compare account transactions in two journal files
|
||||||
|
- [setup](#setup) - check and help set up various installation things
|
||||||
- [test](#test) - run self tests
|
- [test](#test) - run self tests
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -85,6 +85,7 @@ extra-source-files:
|
|||||||
- Hledger/Cli/Commands/Repl.txt
|
- Hledger/Cli/Commands/Repl.txt
|
||||||
- Hledger/Cli/Commands/Roi.txt
|
- Hledger/Cli/Commands/Roi.txt
|
||||||
- Hledger/Cli/Commands/Run.txt
|
- Hledger/Cli/Commands/Run.txt
|
||||||
|
- Hledger/Cli/Commands/Setup.txt
|
||||||
- Hledger/Cli/Commands/Stats.txt
|
- Hledger/Cli/Commands/Stats.txt
|
||||||
- Hledger/Cli/Commands/Tags.txt
|
- Hledger/Cli/Commands/Tags.txt
|
||||||
- Hledger/Cli/Commands/Test.txt
|
- Hledger/Cli/Commands/Test.txt
|
||||||
@ -193,6 +194,7 @@ library:
|
|||||||
- Hledger.Cli.Commands.Rewrite
|
- Hledger.Cli.Commands.Rewrite
|
||||||
- Hledger.Cli.Commands.Roi
|
- Hledger.Cli.Commands.Roi
|
||||||
- Hledger.Cli.Commands.Run
|
- Hledger.Cli.Commands.Run
|
||||||
|
- Hledger.Cli.Commands.Setup
|
||||||
- Hledger.Cli.Commands.Stats
|
- Hledger.Cli.Commands.Stats
|
||||||
- Hledger.Cli.Commands.Tags
|
- Hledger.Cli.Commands.Tags
|
||||||
- Hledger.Cli.CompoundBalanceCommand
|
- Hledger.Cli.CompoundBalanceCommand
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user