summaryrefslogtreecommitdiffhomepage
path: root/CmdLine.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2017-04-30 11:53:10 -0400
committerJoey Hess <joeyh@joeyh.name>2017-04-30 12:15:47 -0400
commit9331a37b178c9142f5e864bbdc5434ea208946cc (patch)
tree6431bc6cd3f09f8c64a51c780f7d549c3a6832ab /CmdLine.hs
parent5ddda2f7684857e90f45c37d030858773e96ee99 (diff)
downloaddebug-me-9331a37b178c9142f5e864bbdc5434ea208946cc.tar.gz
make url work without --debug
Diffstat (limited to 'CmdLine.hs')
-rw-r--r--CmdLine.hs31
1 files changed, 17 insertions, 14 deletions
diff --git a/CmdLine.hs b/CmdLine.hs
index 7a023e7..a1eda5c 100644
--- a/CmdLine.hs
+++ b/CmdLine.hs
@@ -2,6 +2,7 @@ module CmdLine where
import Data.Monoid
import Options.Applicative
+import Network.URI
import Network.Wai.Handler.Warp (Port)
data CmdLine = CmdLine
@@ -19,21 +20,19 @@ data Mode
| ControlMode ControlOpts
data UserOpts = UserOpts
- { cmdToRun :: Maybe (String, [String])
+ { cmdToRun :: Maybe String
}
-type UrlString = String
-
data DeveloperOpts = DeveloperOpts
- { debugUrl :: UrlString
+ { debugUrl :: URI
}
data DownloadOpts = DownloadOpts
- { downloadUrl :: UrlString
+ { downloadUrl :: URI
}
data WatchOpts = WatchOpts
- { watchUrl :: UrlString
+ { watchUrl :: URI
}
data GraphvizOpts = GraphvizOpts
@@ -68,13 +67,14 @@ parseMode = (UserMode <$> parseuser)
<|> (ControlMode <$> parsecontrol)
where
parseuser = UserOpts
- <$> optional ((,)
- <$> strArgument (metavar "cmd")
- <*> many (strArgument (metavar "opts")))
+ <$> optional (strOption
+ ( long "run"
+ <> metavar "command"
+ <> help "program to run (default: login shell)"
+ ))
parsedeveloper = DeveloperOpts
- <$> option str
- ( long "debug"
- <> metavar "url"
+ <$> argument readurl
+ ( metavar "url"
<> help "debug a user on the given url"
)
parsegraphviz = GraphvizOpts
@@ -94,13 +94,13 @@ parseMode = (UserMode <$> parseuser)
<> help "replay log file"
)
parsedownload = DownloadOpts
- <$> option str
+ <$> option readurl
( long "download"
<> metavar "url"
<> help "download log file from server"
)
parsewatch = WatchOpts
- <$> option str
+ <$> option readurl
( long "watch"
<> metavar "url"
<> help "display a debug-me session non-interactively"
@@ -131,3 +131,6 @@ getCmdLine = execParser opts
( fullDesc
<> header "debug-me - provable remote debugging sessions"
)
+
+readurl :: ReadM URI
+readurl = eitherReader $ maybe (Left "url parse error") Right . parseURI