aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/App/Opt.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2022-10-31 09:59:36 -0700
committerJohn MacFarlane <[email protected]>2022-10-31 11:29:23 -0700
commit4a47ffb8ba5f67b5e0e430aa65252a67838a0a92 (patch)
tree35746986f597d59b2ecde73df801fc92905ef7d7 /src/Text/Pandoc/App/Opt.hs
parent3e48d9701d955dc1df27f9cfd2eb5111b2cd9c1f (diff)
Text.Pandoc.App: Change `parseOptionsFromArgs` and `parseOptions`...optinfo
They now return `Either OptInfo Opt`. Add `OptInfo` type. Add `handleOptInfo` function. This performs the IO actions for things like `--version` that were previously done in `parseOptionsFromArgs`. An argument for a `ScriptingEngine` has been added, to facilitate printing custom templates and custom extensions for Lua filters. (However, at this stage nothing is yet done with it.) [API change]
Diffstat (limited to 'src/Text/Pandoc/App/Opt.hs')
-rw-r--r--src/Text/Pandoc/App/Opt.hs21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/Text/Pandoc/App/Opt.hs b/src/Text/Pandoc/App/Opt.hs
index 2c0cef5cd..3ea87de5d 100644
--- a/src/Text/Pandoc/App/Opt.hs
+++ b/src/Text/Pandoc/App/Opt.hs
@@ -18,6 +18,7 @@ Options for pandoc when used as an app.
-}
module Text.Pandoc.App.Opt (
Opt(..)
+ , OptInfo(..)
, LineEnding (..)
, IpynbOutput (..)
, DefaultsState (..)
@@ -55,8 +56,8 @@ import qualified Data.Text as T
import qualified Data.Map as M
import qualified Data.ByteString.Char8 as B8
import Text.Pandoc.Definition (Meta(..), MetaValue(..))
-import Data.Aeson (defaultOptions, Options(..), Result(..), camelTo2,
- genericToJSON, fromJSON)
+import Data.Aeson (defaultOptions, Options(..), Result(..),
+ genericToJSON, fromJSON, camelTo2)
import Data.Aeson.TH (deriveJSON)
import Control.Applicative ((<|>))
import Data.Yaml
@@ -79,6 +80,22 @@ data IpynbOutput =
$(deriveJSON
defaultOptions{ fieldLabelModifier = map toLower . drop 11 } ''IpynbOutput)
+-- | Option parser results requesting informational output.
+data OptInfo =
+ BashCompletion
+ | ListInputFormats
+ | ListOutputFormats
+ | ListExtensions (Maybe Text)
+ | ListHighlightLanguages
+ | ListHighlightStyles
+ | PrintDefaultTemplate (Maybe FilePath) Text
+ | PrintDefaultDataFile (Maybe FilePath) Text
+ | PrintHighlightStyle (Maybe FilePath) Text
+ | VersionInfo
+ | Help
+ | OptError PandocError
+ deriving (Show, Generic)
+
-- | Data structure for command line options.
data Opt = Opt
{ optTabStop :: Int -- ^ Number of spaces per tab