Link names
This commit is contained in:
parent
0001730497
commit
5d241e19f8
36
app/Main.hs
36
app/Main.hs
|
@ -12,6 +12,7 @@ data Args = Args
|
||||||
, directory :: FilePath
|
, directory :: FilePath
|
||||||
, fileHead :: FilePath
|
, fileHead :: FilePath
|
||||||
, verbose :: Bool
|
, verbose :: Bool
|
||||||
|
, refs :: Bool
|
||||||
, cgi :: Bool
|
, cgi :: Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +37,9 @@ args = Args
|
||||||
( long "verbose"
|
( long "verbose"
|
||||||
<> short 'v'
|
<> short 'v'
|
||||||
<> help "Verbose mode")
|
<> help "Verbose mode")
|
||||||
|
<*> switch
|
||||||
|
( long "references"
|
||||||
|
<> help "Generate link reference based on first line of document" )
|
||||||
<*> switch
|
<*> switch
|
||||||
( long "cgi"
|
( long "cgi"
|
||||||
<> help "Output gemini file header")
|
<> help "Output gemini file header")
|
||||||
|
@ -49,16 +53,24 @@ main = parseArgs =<< execParser opts
|
||||||
<> header "Generate a gemini page index")
|
<> header "Generate a gemini page index")
|
||||||
|
|
||||||
parseArgs :: Args -> IO()
|
parseArgs :: Args -> IO()
|
||||||
parseArgs (Args t d h False False) = do
|
parseArgs (Args t dir h v c r) = do
|
||||||
putStrLn $ "# " ++ t
|
if c then do
|
||||||
putStrLn h
|
putStr success
|
||||||
mkIndex =<< getDirectoryContents d
|
putStrLn $ "# " ++ t
|
||||||
parseArgs (Args t d h False True) = do
|
else putStrLn $ "# " ++ t
|
||||||
putStr success
|
if not (null h)
|
||||||
putStrLn $ "# " ++ t
|
then putStr $ "\n\n" ++ h ++ "\n\n"
|
||||||
putStrLn h
|
else putStr "\n"
|
||||||
mkIndex =<< getDirectoryContents d
|
mkIndex r . filter (isSuffixOf ".gmi") =<< getDirectoryContents dir
|
||||||
parseArgs _ = putStrLn "fiets"
|
|
||||||
|
|
||||||
mkIndex :: [String] -> IO ()
|
mkIndex :: Bool -> [String] -> IO ()
|
||||||
mkIndex = mapM_ (putStrLn . ("=> " ++)) . filter (isSuffixOf ".gmi")
|
mkIndex True l = mapM_ (putStrLn . ("=> " ++)) l
|
||||||
|
-- where firstLine f = do
|
||||||
|
-- print $ head . lines =<< readFile f
|
||||||
|
mkIndex False l = mapM_ (putStrLn . ("=> " ++)) l
|
||||||
|
|
||||||
|
firstLine :: FilePath -> IO ()
|
||||||
|
firstLine f = do
|
||||||
|
putStr . head . lines =<< readFile f
|
||||||
|
|
||||||
|
--compose = (++) <$> ("=> " ++) <*> (show . length) <*> (head . lines =<< readFile)
|
||||||
|
|
Loading…
Reference in a new issue