summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-03-05 10:52:10 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2023-03-05 10:52:10 +0100
commit1124ad339c5b1d91d1c5f5bde18e3146b016c5bf (patch)
tree38ab589232f15efbd475141311f666e26cc3bd27
parentMAJOR work on handlingar path. (diff)
downloadvimwiki-scripts-1124ad339c5b1d91d1c5f5bde18e3146b016c5bf.tar.gz
vimwiki-scripts-1124ad339c5b1d91d1c5f5bde18e3146b016c5bf.tar.xz
Add mode switch in top main.
-rw-r--r--hs/src/Config.hs2
-rw-r--r--hs/src/Handlingar.hs5
-rw-r--r--hs/src/Html.hs5
-rw-r--r--hs/src/main.hs11
4 files changed, 15 insertions, 8 deletions
diff --git a/hs/src/Config.hs b/hs/src/Config.hs
index e0b846c..86356a2 100644
--- a/hs/src/Config.hs
+++ b/hs/src/Config.hs
@@ -107,7 +107,7 @@ confParser ini =
runParser :: Text -> Either String Configuration
runParser t = confParser <$> parseIni t
-parseCmdline = execParser opts
+parseCmdline args = execParserPure defaultPrefs opts args & handleParseResult
defaultConf = Configuration
{ _output = OutputConfig
diff --git a/hs/src/Handlingar.hs b/hs/src/Handlingar.hs
index 2664b08..16d61ce 100644
--- a/hs/src/Handlingar.hs
+++ b/hs/src/Handlingar.hs
@@ -32,7 +32,6 @@ import Data.Text.IO
( putStrLn
, writeFile
)
-import System.Environment (getArgs)
import Data.Default (def)
import Control.Monad.State.Lazy
import Data.Text.Encoding.Base64 (encodeBase64)
@@ -358,8 +357,8 @@ f bs is a b = do
-- renumber :: Int -> [Blocks] -> [Blocks]
-main = do
- args <- getArgs
+main :: [String] -> IO ()
+main args = do
case args of
[file, heading] -> do
diff --git a/hs/src/Html.hs b/hs/src/Html.hs
index 0eee74f..b539772 100644
--- a/hs/src/Html.hs
+++ b/hs/src/Html.hs
@@ -325,8 +325,9 @@ copyFromDatadir filename datadirs destination = do
source:_ -> copyFile source destination
-main = do
- args <- parseCmdline
+main :: [String] -> IO ()
+main args = do
+ args <- parseCmdline args
confDir <- getUserConfigDir "vimwiki"
diff --git a/hs/src/main.hs b/hs/src/main.hs
index 017ee66..d6b2738 100644
--- a/hs/src/main.hs
+++ b/hs/src/main.hs
@@ -1,9 +1,16 @@
module Main where
+import System.Environment (getArgs)
+
import qualified Html
--- import qualified Handlingar
+import qualified Handlingar
-main = Html.main
+main = do
+ args <- getArgs
+ case args of
+ ("handlingar":xs) -> Handlingar.main xs
+ ("html":xs) -> Html.main xs
+ _ -> putStrLn "Usage: ./main [handlingar|html]"
-- TODO