fix: Remove references to $COLUMNS
As noted in Hledger.Utils.IO, COLUMNS is a bashism that isn't particularly usable for our purposes (for one thing, it isn't updated when the terminal is resized)
This commit is contained in:
parent
a24c39f13f
commit
cde77eace0
@ -550,9 +550,8 @@ data CliOpts = CliOpts {
|
|||||||
,no_new_accounts_ :: Bool -- add
|
,no_new_accounts_ :: Bool -- add
|
||||||
,width_ :: Maybe String -- ^ the --width value provided, if any
|
,width_ :: Maybe String -- ^ the --width value provided, if any
|
||||||
,available_width_ :: Int -- ^ estimated usable screen width, based on
|
,available_width_ :: Int -- ^ estimated usable screen width, based on
|
||||||
-- 1. the COLUMNS env var, if set
|
-- 1. the width reported by the terminal, if supported
|
||||||
-- 2. the width reported by the terminal, if supported
|
-- 2. the default (80)
|
||||||
-- 3. the default (80)
|
|
||||||
,progstarttime_ :: POSIXTime -- system POSIX time at start
|
,progstarttime_ :: POSIXTime -- system POSIX time at start
|
||||||
} deriving (Show)
|
} deriving (Show)
|
||||||
|
|
||||||
@ -615,9 +614,8 @@ rawOptsToCliOpts rawopts = do
|
|||||||
usecolor <- useColorOnStdout
|
usecolor <- useColorOnStdout
|
||||||
let iopts = rawOptsToInputOpts day usecolor postingaccttags rawopts
|
let iopts = rawOptsToInputOpts day usecolor postingaccttags rawopts
|
||||||
rspec <- either error' pure $ rawOptsToReportSpec day usecolor rawopts -- PARTIAL:
|
rspec <- either error' pure $ rawOptsToReportSpec day usecolor rawopts -- PARTIAL:
|
||||||
mcolumns <- readMay <$> getEnvSafe "COLUMNS"
|
|
||||||
mtermwidth <- getTerminalWidth
|
mtermwidth <- getTerminalWidth
|
||||||
let availablewidth = NE.head $ NE.fromList $ catMaybes [mcolumns, mtermwidth, Just defaultWidth] -- PARTIAL: fromList won't fail because non-null list
|
let availablewidth = NE.head $ NE.fromList $ catMaybes [mtermwidth, Just defaultWidth] -- PARTIAL: fromList won't fail because non-null list
|
||||||
return defcliopts {
|
return defcliopts {
|
||||||
rawopts_ = rawopts
|
rawopts_ = rawopts
|
||||||
,command_ = command
|
,command_ = command
|
||||||
@ -763,8 +761,7 @@ rulesFilePathFromOpts opts = do
|
|||||||
maybe (return Nothing) (fmap Just . expandPath d) $ mrules_file_ $ inputopts_ opts
|
maybe (return Nothing) (fmap Just . expandPath d) $ mrules_file_ $ inputopts_ opts
|
||||||
|
|
||||||
-- -- | Get the width in characters to use for console output.
|
-- -- | Get the width in characters to use for console output.
|
||||||
-- -- This comes from the --width option, or the COLUMNS environment
|
-- -- This comes from the --width option, or the current terminal width, or 80.
|
||||||
-- -- variable, or (on posix platforms) the current terminal width, or 80.
|
|
||||||
-- -- Will raise a parse error for a malformed --width argument.
|
-- -- Will raise a parse error for a malformed --width argument.
|
||||||
-- widthFromOpts :: CliOpts -> Int
|
-- widthFromOpts :: CliOpts -> Int
|
||||||
-- widthFromOpts CliOpts{width_=Nothing, available_width_=w} = w
|
-- widthFromOpts CliOpts{width_=Nothing, available_width_=w} = w
|
||||||
@ -779,7 +776,7 @@ rulesFilePathFromOpts opts = do
|
|||||||
-- and also the description column width if specified (following the main width, comma-separated).
|
-- and also the description column width if specified (following the main width, comma-separated).
|
||||||
-- The widths will be as follows:
|
-- The widths will be as follows:
|
||||||
-- @
|
-- @
|
||||||
-- no --width flag - overall width is the available width (COLUMNS, or posix terminal width, or 80); description width is unspecified (auto)
|
-- no --width flag - overall width is the available width (or terminal width, or 80); description width is unspecified (auto)
|
||||||
-- --width W - overall width is W, description width is auto
|
-- --width W - overall width is W, description width is auto
|
||||||
-- --width W,D - overall width is W, description width is D
|
-- --width W,D - overall width is W, description width is D
|
||||||
-- @
|
-- @
|
||||||
|
|||||||
@ -65,7 +65,7 @@ aregistermode = hledgerCommandMode
|
|||||||
#else
|
#else
|
||||||
"terminal width"
|
"terminal width"
|
||||||
#endif
|
#endif
|
||||||
++ " or $COLUMNS). -wN,M sets description width as well."
|
++ "). -wN,M sets description width as well."
|
||||||
)
|
)
|
||||||
,flagNone ["align-all"] (setboolopt "align-all") "guarantee alignment across all lines (slower)"
|
,flagNone ["align-all"] (setboolopt "align-all") "guarantee alignment across all lines (slower)"
|
||||||
,outputFormatFlag ["txt","html","csv","tsv","json"]
|
,outputFormatFlag ["txt","html","csv","tsv","json"]
|
||||||
|
|||||||
@ -67,7 +67,7 @@ registermode = hledgerCommandMode
|
|||||||
#else
|
#else
|
||||||
"terminal width"
|
"terminal width"
|
||||||
#endif
|
#endif
|
||||||
++ " or $COLUMNS). -wN,M sets description width as well."
|
++ "). -wN,M sets description width as well."
|
||||||
)
|
)
|
||||||
,flagNone ["align-all"] (setboolopt "align-all") "guarantee alignment across all lines (slower)"
|
,flagNone ["align-all"] (setboolopt "align-all") "guarantee alignment across all lines (slower)"
|
||||||
,flagReq ["base-url"] (\s opts -> Right $ setopt "base-url" s opts) "URLPREFIX" "in html output, generate links to hledger-web, with this prefix. (Usually the base url shown by hledger-web; can also be relative.)"
|
,flagReq ["base-url"] (\s opts -> Right $ setopt "base-url" s opts) "URLPREFIX" "in html output, generate links to hledger-web, with this prefix. (Usually the base url shown by hledger-web; can also be relative.)"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user