Gemini file header

This commit is contained in:
Nox Sluijtman 2023-07-31 00:29:26 +02:00
parent 61746521df
commit 0dafb22a60

View file

@ -1,10 +1,12 @@
module Main where
import System.Directory
import System.Environment
import Options.Applicative
import Data.List
success :: String
success = "20 text/gemini; lang=en; charset=utf-8\r\n"
data Args = Args
{ title :: String
, directory :: FilePath
@ -28,29 +30,27 @@ args = Args
( long "header"
<> short 'H'
<> value ""
<> help "File with header text" )
<> help "Header text" )
<*> switch
( long "verbose"
<> short 'v'
<> help "Verbose mode")
--mapM_ putStrLn =<< getDirectoryContents =<< getEnv "FIETS"
main :: IO ()
main = parseArgs =<< execParser opts
where
opts = info ( args <**> helper)
( fullDesc
<> progDesc "Generate gemini page index"
<> header "fucking kill me")
<> progDesc "Generate gemini page index"
<> header "Generate a gemini page index")
parseArgs :: Args -> IO()
parseArgs (Args t d h False) = do
putStr success
putStrLn $ "# " ++ t
putStrLn =<< readFile h
putStrLn h
mkIndex =<< getDirectoryContents d
parseArgs _ = putStrLn "fiets"
mkIndex :: [String] -> IO ()
--mkIndex = mapM_ (putStrLn . ("=> " ++))
mkIndex = mapM_ (putStrLn . ("=> " ++)) . filter (isSuffixOf ".gmi")