From d6dbe32df6f1a01c95f9293023e2d73872fa39fe Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 28 Dec 2024 13:09:21 +0530 Subject: Add cli arg parsing for starting in given mode --- bin/Main.hs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'bin/Main.hs') 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 : Run program in mode. (search | hints)" + ] -- cgit v1.3.1