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.
This commit is contained in:
Simon Michael 2023-01-29 16:21:15 -10:00
parent 6589b506ed
commit 3f3401f8ad
2 changed files with 34 additions and 0 deletions

View File

@ -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)

View File

@ -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