summaryrefslogtreecommitdiff
path: root/pandoc.hs
diff options
context:
space:
mode:
Diffstat (limited to 'pandoc.hs')
-rw-r--r--pandoc.hs34
1 files changed, 25 insertions, 9 deletions
diff --git a/pandoc.hs b/pandoc.hs
index 3524eb31d..b88e847f6 100644
--- a/pandoc.hs
+++ b/pandoc.hs
@@ -82,16 +82,37 @@ main = do
rawArgs <- map UTF8.decodeArg <$> getArgs
prg <- getProgName
- let (actions, args, errors) = getOpt Permute options rawArgs
+ let (actions, args, unrecognizedOpts, errors) =
+ getOpt' Permute options rawArgs
- unless (null errors) $
- err 2 $ concat $ errors ++
- ["Try " ++ prg ++ " --help for more information."]
+ let unknownOptionErrors = foldr addDeprecationNote [] unrecognizedOpts
+
+ unless (null errors && null unknownOptionErrors) $
+ err 2 $ concat errors ++ unlines unknownOptionErrors ++
+ ("Try " ++ prg ++ " --help for more information.")
-- thread option data structure through all supplied option actions
opts <- foldl (>>=) (return defaultOpts) actions
convertWithOpts opts args
+addDeprecationNote :: String -> [String] -> [String]
+addDeprecationNote "--smart" =
+ (("--smart has been removed. Use +smart or -smart extension instead.\n" ++
+ "For example: pandoc -f markdown+smart -t markdown-smart.") :)
+addDeprecationNote "-S" = addDeprecationNote "--smart"
+addDeprecationNote "--old-dashes" =
+ ("--old-dashes has been removed." :)
+addDeprecationNote "--no-wrap" =
+ ("--no-wrap has been removed. Use --wrap=none instead." :)
+addDeprecationNote "--chapters" =
+ ("--chapters has been removed. Use --top-level-division=chapter instead." :)
+addDeprecationNote "--reference-docx" =
+ ("--reference-docx has been removed. Use --reference-doc instead." :)
+addDeprecationNote "--reference-odt" =
+ ("--reference-odt has been removed. Use --reference-doc instead." :)
+addDeprecationNote x =
+ (("Unknown option " ++ x ++ ".") :)
+
convertWithOpts :: Opt -> [FilePath] -> IO ()
convertWithOpts opts args = do
let Opt { optTabStop = tabStop
@@ -1283,11 +1304,6 @@ options =
]
--- TODO: possibly add code to give a more informative message
--- if people try to use options that have been removed in 2.0,
--- e.g. --smart/-S, --old-dashes, --no-wrap, --chapters,
--- --reference-docx, --reference-odt
-
addMetadata :: String -> MetaValue -> M.Map String MetaValue
-> M.Map String MetaValue
addMetadata k v m = case M.lookup k m of