From 3f3401f8ad55b86809539605756f01bd2cf563f8 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sun, 29 Jan 2023 16:21:15 -1000 Subject: [PATCH] imp: cli: Hledger.Cli.Script convenience import for scripts Hledger.Cli.Script is a convenient prelude for use in scripts, reducing import boilerplate. It currently re-exports: Control.Monad Data.Either Data.List Data.Maybe Data.Ord Data.Time Text.Printf hiding (formatString) Data.Text (Text, pack, unpack) Safe hiding (at) System.Directory System.Environment System.Exit System.FilePath System.Process Hledger Hledger.Cli Hledger.Cli.Main (argsToCliOpts) but not (much of) Data.Text or Data.Text.IO, as those need to be imported qualified. --- hledger/Hledger/Cli/Script.hs | 33 +++++++++++++++++++++++++++++++++ hledger/package.yaml | 1 + 2 files changed, 34 insertions(+) create mode 100644 hledger/Hledger/Cli/Script.hs diff --git a/hledger/Hledger/Cli/Script.hs b/hledger/Hledger/Cli/Script.hs new file mode 100644 index 000000000..0985177d8 --- /dev/null +++ b/hledger/Hledger/Cli/Script.hs @@ -0,0 +1,33 @@ +{-| +A convenient module to import in hledger scripts, +aiming to provide the most useful imports and reduce boilerplate. +|-} + +{-# LANGUAGE PackageImports #-} + +module Hledger.Cli.Script +( module Script +) +where + +import Control.Monad as Script +import Data.Either as Script +import Data.List as Script +import Data.Maybe as Script +import Data.Ord as Script +-- import Data.String.QQ (s) -- https://github.com/audreyt/string-qq/pull/3 +import Data.Time as Script +import Text.Printf as Script hiding (formatString) +import "text" Data.Text as Script (Text, pack, unpack) + -- can't re-export much of Data.Text & Data.Text.IO, they need to be qualified +import Safe as Script hiding (at) +-- import qualified System.Console.CmdArgs.Explicit as Script +import System.Directory as Script +import System.Environment as Script +import System.Exit as Script +import System.FilePath as Script +import System.Process as Script + +import Hledger as Script +import Hledger.Cli as Script +import Hledger.Cli.Main as Script (argsToCliOpts) diff --git a/hledger/package.yaml b/hledger/package.yaml index 09283f3bc..6fab9757f 100644 --- a/hledger/package.yaml +++ b/hledger/package.yaml @@ -146,6 +146,7 @@ library: - Hledger.Cli.DocFiles - Hledger.Cli.Utils - Hledger.Cli.Anon + - Hledger.Cli.Script - Hledger.Cli.Version - Hledger.Cli.Commands - Hledger.Cli.Commands.Accounts