From 0dafb22a600f9fa6a26ce05dd0637b54cfeca6e8 Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Mon, 31 Jul 2023 00:29:26 +0200 Subject: [PATCH] Gemini file header --- app/Main.hs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index d0140c9..7af805b 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -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")