diff options
| author | Akshay Nair <phenax5@gmail.com> | 2024-12-28 13:09:21 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2024-12-28 13:53:44 +0530 |
| commit | d6dbe32df6f1a01c95f9293023e2d73872fa39fe (patch) | |
| tree | d9a9e667eef416c03745a054118f21ed84ad49e9 /bin | |
| parent | 98af698a806e41904368c0114f9d8d9f377d9c09 (diff) | |
| download | chelleport-d6dbe32df6f1a01c95f9293023e2d73872fa39fe.tar.gz chelleport-d6dbe32df6f1a01c95f9293023e2d73872fa39fe.zip | |
Add cli arg parsing for starting in given mode
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/Main.hs | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/bin/Main.hs b/bin/Main.hs index ebc9a39..007fb5e 100644 --- a/bin/Main.hs +++ b/bin/Main.hs @@ -1,6 +1,32 @@ module Main where import qualified Chelleport +import Chelleport.Args (Configuration (configShowHelp)) +import qualified Chelleport.Args as Args +import qualified System.Environment +import System.Exit (exitFailure) main :: IO () -main = Chelleport.run +main = do + args <- System.Environment.getArgs + case Args.parseArgs args of + Right config + | configShowHelp config -> showHelp + | otherwise -> Chelleport.run config + Left err -> do + showHelp + putStrLn $ "[Error] " ++ err + exitFailure + +showHelp :: IO () +showHelp = + putStrLn . unlines $ + [ "Control your mouse with your keyboard", + "See https://github.com/phenax/chelleport for more information", + "", + "Usage: chelleport [FLAGS]", + "", + "Flags:", + " --help: Help menu. This thing right here", + " -m <mode>, --mode <mode>: Run program in mode. (search | hints)" + ] |
