2020-08-04 17:36:31 +02:00
|
|
|
{-# LANGUAGE RecordWildCards #-}
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
module Main where
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
import Options.Applicative
|
|
|
|
import Data.Semigroup ((<>))
|
|
|
|
|
2020-08-06 00:30:25 +02:00
|
|
|
import qualified Transforms
|
|
|
|
import qualified Keyboard
|
|
|
|
import qualified App
|
2020-08-04 17:36:31 +02:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
data CommandArgs = CommandArgs
|
2020-08-06 00:30:25 +02:00
|
|
|
{ transforms :: String
|
2020-08-04 17:36:31 +02:00
|
|
|
} deriving (Eq, Show)
|
|
|
|
|
|
|
|
parseArgs :: Parser CommandArgs
|
|
|
|
parseArgs =
|
|
|
|
CommandArgs <$> strOption
|
2020-08-06 00:30:25 +02:00
|
|
|
( long "transforms"
|
|
|
|
<> short 't'
|
|
|
|
<> help "String of transforms where (e.g. \"HHVS12VHVHS3\")" )
|
2020-08-04 17:36:31 +02:00
|
|
|
|
|
|
|
main :: IO ()
|
|
|
|
main = do
|
2020-08-06 00:30:25 +02:00
|
|
|
CommandArgs{..} <- execParser opts
|
|
|
|
case Transforms.fromString transforms of
|
|
|
|
Nothing -> putStrLn "You must provide valid input (e.g. \"HHVS12VHVHS3\")"
|
|
|
|
Just xs -> print $ foldl App.transform Keyboard.qwerty xs
|
2020-08-04 17:36:31 +02:00
|
|
|
where
|
|
|
|
opts = info (parseArgs <**> helper)
|
|
|
|
( fullDesc
|
2020-08-06 00:30:25 +02:00
|
|
|
<> progDesc "Transform a QWERTY keyboard using a string of commands")
|