diff --git a/hledger/Hledger/Cli/Commands.hs b/hledger/Hledger/Cli/Commands.hs index 31a32f477..8cb6ea8e7 100644 --- a/hledger/Hledger/Cli/Commands.hs +++ b/hledger/Hledger/Cli/Commands.hs @@ -49,6 +49,7 @@ module Hledger.Cli.Commands ( ,module Hledger.Cli.Commands.Register ,module Hledger.Cli.Commands.Rewrite ,module Hledger.Cli.Commands.Run + ,module Hledger.Cli.Commands.Setup ,module Hledger.Cli.Commands.Stats ,module Hledger.Cli.Commands.Tags ) @@ -99,6 +100,7 @@ import Hledger.Cli.Commands.Register import Hledger.Cli.Commands.Rewrite import Hledger.Cli.Commands.Roi import Hledger.Cli.Commands.Run +import Hledger.Cli.Commands.Setup import Hledger.Cli.Commands.Stats import Hledger.Cli.Commands.Tags import Hledger.Cli.Utils (tests_Cli_Utils) @@ -138,6 +140,7 @@ builtinCommands = [ ,(roimode , roi) ,(runmode , runOrReplStub) ,(replmode , runOrReplStub) + ,(setupmode , setup) ,(statsmode , stats) ,(tagsmode , tags) ,(testmode , testcmd) @@ -292,6 +295,7 @@ commandsList progversion othercmds = ," diff compare an account's transactions in two journals" ,"+git save or view journal file history simply in git" -- hledger-git ,"+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" ,"" -----------------------------------------80------------------------------------- diff --git a/hledger/Hledger/Cli/Commands/Setup.hs b/hledger/Hledger/Cli/Commands/Setup.hs new file mode 100644 index 000000000..67b5baf1a --- /dev/null +++ b/hledger/Hledger/Cli/Commands/Setup.hs @@ -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 diff --git a/hledger/Hledger/Cli/Commands/Setup.md b/hledger/Hledger/Cli/Commands/Setup.md new file mode 100644 index 000000000..5a251b715 --- /dev/null +++ b/hledger/Hledger/Cli/Commands/Setup.md @@ -0,0 +1,9 @@ +## setup + +Check and help set up various installation things. + +```flags +Flags: +no command-specific flags +``` + diff --git a/hledger/Hledger/Cli/Commands/Setup.txt b/hledger/Hledger/Cli/Commands/Setup.txt new file mode 100644 index 000000000..409c9b4c3 --- /dev/null +++ b/hledger/Hledger/Cli/Commands/Setup.txt @@ -0,0 +1,6 @@ +setup + +Check and help set up various installation things. + +Flags: +no command-specific flags diff --git a/hledger/Hledger/Cli/Commands/commands.m4 b/hledger/Hledger/Cli/Commands/commands.m4 index c8869f2fe..46e2cb6e0 100644 --- a/hledger/Hledger/Cli/Commands/commands.m4 +++ b/hledger/Hledger/Cli/Commands/commands.m4 @@ -70,6 +70,7 @@ _command_({{Rewrite}}) _command_({{Check}}) _command_({{Diff}}) +_command_({{Setup}}) _command_({{Test}}) }})m4_dnl diff --git a/hledger/hledger.cabal b/hledger/hledger.cabal index 50c9003d0..96ea9a3f3 100644 --- a/hledger/hledger.cabal +++ b/hledger/hledger.cabal @@ -87,6 +87,7 @@ extra-source-files: Hledger/Cli/Commands/Repl.txt Hledger/Cli/Commands/Roi.txt Hledger/Cli/Commands/Run.txt + Hledger/Cli/Commands/Setup.txt Hledger/Cli/Commands/Stats.txt Hledger/Cli/Commands/Tags.txt Hledger/Cli/Commands/Test.txt @@ -139,6 +140,7 @@ library Hledger.Cli.Commands.Rewrite Hledger.Cli.Commands.Roi Hledger.Cli.Commands.Run + Hledger.Cli.Commands.Setup Hledger.Cli.Commands.Stats Hledger.Cli.Commands.Tags Hledger.Cli.CompoundBalanceCommand diff --git a/hledger/hledger.m4.md b/hledger/hledger.m4.md index 0fc9b7a6e..c364113a1 100644 --- a/hledger/hledger.m4.md +++ b/hledger/hledger.m4.md @@ -702,6 +702,7 @@ Here are those commands and the formats currently supported: | prices | | | | | | | rewrite | | | | | | | roi | | | | | | +| setup | | | | | | | stats | | | | | | | stockquotes | | | | | | | 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 - [diff](#diff) - compare account transactions in two journal files +- [setup](#setup) - check and help set up various installation things - [test](#test) - run self tests diff --git a/hledger/package.yaml b/hledger/package.yaml index f03a66b88..38a1b2102 100644 --- a/hledger/package.yaml +++ b/hledger/package.yaml @@ -85,6 +85,7 @@ extra-source-files: - Hledger/Cli/Commands/Repl.txt - Hledger/Cli/Commands/Roi.txt - Hledger/Cli/Commands/Run.txt +- Hledger/Cli/Commands/Setup.txt - Hledger/Cli/Commands/Stats.txt - Hledger/Cli/Commands/Tags.txt - Hledger/Cli/Commands/Test.txt @@ -193,6 +194,7 @@ library: - Hledger.Cli.Commands.Rewrite - Hledger.Cli.Commands.Roi - Hledger.Cli.Commands.Run + - Hledger.Cli.Commands.Setup - Hledger.Cli.Commands.Stats - Hledger.Cli.Commands.Tags - Hledger.Cli.CompoundBalanceCommand