diff options
-rw-r--r-- | CmdLine.hs | 12 | ||||
-rw-r--r-- | Role/User.hs | 8 | ||||
-rw-r--r-- | debug-me.cabal | 2 |
3 files changed, 15 insertions, 7 deletions
@@ -16,7 +16,7 @@ data Mode | ServerMode ServerOpts data UserOpts = UserOpts - { + { cmdToRun :: Maybe (String, [String]) } data DeveloperOpts = DeveloperOpts @@ -41,12 +41,16 @@ parseCmdLine :: Parser CmdLine parseCmdLine = CmdLine <$> parseMode parseMode :: Parser Mode -parseMode = (GraphvizMode <$> parsegraphviz) +parseMode = (UserMode <$> parseuser) + <|> (DeveloperMode <$> parsedeveloper) <|> (ReplayMode <$> parsereplay) + <|> (GraphvizMode <$> parsegraphviz) <|> (ServerMode <$> parseserver) - <|> (DeveloperMode <$> parsedeveloper) - <|> pure (UserMode (UserOpts {})) -- default, so last where + parseuser = UserOpts + <$> optional ((,) + <$> strArgument (metavar "cmd") + <*> many (strArgument (metavar "opts"))) parsegraphviz = GraphvizOpts <$> option str ( long "graphviz" diff --git a/Role/User.hs b/Role/User.hs index efbbb24..99a8a1a 100644 --- a/Role/User.hs +++ b/Role/User.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE OverloadedStrings, TupleSections #-} module Role.User where @@ -19,8 +19,10 @@ import System.Exit import qualified Data.ByteString as B import Data.List.NonEmpty (NonEmpty(..), toList) import Data.Monoid +import Data.Maybe import Data.Time.Clock.POSIX import System.IO +import System.Environment run :: UserOpts -> IO ExitCode run os = do @@ -44,7 +46,9 @@ run os = do return exitstatus shellCommand :: UserOpts -> IO (String, [String]) -shellCommand os = return ("dash", []) +shellCommand os = case cmdToRun os of + Just v -> return v + Nothing -> (, []) . fromMaybe "bash" <$> lookupEnv "SHELL" -- | Log of recent Activity, with the most recent first. type Backlog = NonEmpty Log diff --git a/debug-me.cabal b/debug-me.cabal index 54fd56b..a913db3 100644 --- a/debug-me.cabal +++ b/debug-me.cabal @@ -63,10 +63,10 @@ Executable debug-me Role.Developer Role.User Session - Types Serialization Server SessionID + Types Val WebSockets |