Gemini file header
This commit is contained in:
parent
61746521df
commit
0dafb22a60
14
app/Main.hs
14
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")
|
||||
<> 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")
|
||||
|
|
Loading…
Reference in a new issue