about summary refs log tree commit diff
path: root/scratch/brilliant/Main.hs
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-08-05T22·30+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-08-05T22·36+0100
commitd45685e2459df4c73702a854309646ae1e146eec (patch)
treeacc7935f2900c39ea1f3a59ebe4cd0b5d0bdf755 /scratch/brilliant/Main.hs
parent244503bba91c9a99c9ab5a6a74b74d5c9bd9667e (diff)
Apply a series of transformation to a QWERTY keyboard
TL;DR:
- Accept input from the CLI
- Add a project README.md
Diffstat (limited to 'scratch/brilliant/Main.hs')
-rw-r--r--scratch/brilliant/Main.hs36
1 files changed, 12 insertions, 24 deletions
diff --git a/scratch/brilliant/Main.hs b/scratch/brilliant/Main.hs
index 999771f55836..4cc6ac1101c2 100644
--- a/scratch/brilliant/Main.hs
+++ b/scratch/brilliant/Main.hs
@@ -5,41 +5,29 @@ module Main where
 import Options.Applicative
 import Data.Semigroup ((<>))
 
-import qualified System.Environment as Env
+import qualified Transforms
+import qualified Keyboard
+import qualified App
 --------------------------------------------------------------------------------
 
 data CommandArgs = CommandArgs
-  { hello :: String
-  , quiet :: Bool
-  , enthusiasm :: Int
+  { transforms :: String
   } deriving (Eq, Show)
 
 parseArgs :: Parser CommandArgs
 parseArgs =
   CommandArgs <$> strOption
-                  ( long "hello"
-                 <> metavar "TARGET"
-                 <> help "Target for the greeting" )
-              <*> switch
-                  ( long "quiet"
-                 <> short 'q'
-                 <> help "Whether to be quiet" )
-              <*> option auto
-                  ( long "enthusiasm"
-                 <> help "How enthusiastic to greet"
-                 <> showDefault
-                 <> value 1
-                 <> metavar "INT" )
+                  ( long "transforms"
+                 <> short 't'
+                 <> help "String of transforms where (e.g. \"HHVS12VHVHS3\")" )
 
 main :: IO ()
 main = do
-  args <- execParser opts
-  greet args
+  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
   where
     opts = info (parseArgs <**> helper)
       ( fullDesc
-     <> progDesc "Print a greeting for TARGET"
-     <> header "header - a test for optparse-applicative" )
-
-greet :: CommandArgs -> IO ()
-greet CommandArgs{..} = putStrLn $ "Hello, " ++ hello ++ replicate enthusiasm '!'
+     <> progDesc "Transform a QWERTY keyboard using a string of commands")