mirror of
https://github.com/The1Penguin/org-to-mafiauniverse.git
synced 2024-11-21 17:58:12 +00:00
Switched autoformatter
This commit is contained in:
parent
cea8d45ddd
commit
3b6daaba8e
35
app/Main.hs
35
app/Main.hs
@ -1,45 +1,46 @@
|
||||
module Main where
|
||||
|
||||
import Control.Applicative hiding (some)
|
||||
import Control.Monad
|
||||
import Data.Functor
|
||||
import Data.Void
|
||||
import System.Environment
|
||||
import System.Exit
|
||||
import Text.Megaparsec hiding (satisfy)
|
||||
import Text.Megaparsec.Char
|
||||
import Control.Applicative hiding (some)
|
||||
import Control.Monad
|
||||
import Data.Functor
|
||||
import Data.Void
|
||||
import System.Environment
|
||||
import System.Exit
|
||||
import Text.Megaparsec hiding (satisfy)
|
||||
import Text.Megaparsec.Char
|
||||
|
||||
type Parser = Parsec Void String
|
||||
|
||||
parseHelper :: Parser String -> String -> String
|
||||
parseHelper parser x = case parse parser "" x of
|
||||
Left bundle -> error $ errorBundlePretty bundle
|
||||
Right text -> text
|
||||
Right text -> text
|
||||
|
||||
parseFile :: String -> String
|
||||
parseFile = unlines . map (parseHelper fileParser) . lines
|
||||
|
||||
fileParser :: Parser String
|
||||
fileParser = undefined
|
||||
fileParser = try $
|
||||
string "* " <|>
|
||||
string "** "
|
||||
|
||||
parseCli :: [String] -> IO String
|
||||
parseCli [] = return usage
|
||||
parseCli [x] =
|
||||
parseCli [] = return usage
|
||||
parseCli [x] =
|
||||
if head x /= '-'
|
||||
then parseFile <$> readFile x
|
||||
else return $ useArgs $ parseHelper argParse x
|
||||
parseCli [x, _] = return $ useArgs $ parseHelper argParse x
|
||||
parseCli _ = fail "Too many arugemnts"
|
||||
parseCli _ = fail "Too many arugemnts"
|
||||
|
||||
argParse :: Parser String
|
||||
argParse =
|
||||
string "-" >> some alphaNumChar
|
||||
argParse = string "-" >> some alphaNumChar
|
||||
|
||||
useArgs :: String -> String
|
||||
useArgs [] = ""
|
||||
useArgs [] = ""
|
||||
useArgs ('h' : _) = usage
|
||||
useArgs ('v' : _) = version
|
||||
useArgs (_ : xs) = useArgs xs
|
||||
useArgs (_ : xs) = useArgs xs
|
||||
|
||||
usage :: String
|
||||
usage = "Usage: otm [-hv] [file]"
|
||||
|
Loading…
Reference in New Issue
Block a user