summaryrefslogtreecommitdiff
path: root/CmdLine
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-07-09 11:49:52 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-07-09 11:52:47 -0400
commit6ddffe0f0e64a87fd924f736941fa242e0d740a6 (patch)
tree94bc5fed6512ea3cfab47b274cf5534edf889b77 /CmdLine
parent1e4c1adeae64baa4eb30fd7e1171620c27e0e17f (diff)
let optparse-applicative handle the usage display when run w/o command or bad command
Still generating the list of commands myself, to get it sorted into sections and with short synopses.
Diffstat (limited to 'CmdLine')
-rw-r--r--CmdLine/GitAnnex.hs11
-rw-r--r--CmdLine/GitAnnexShell.hs4
-rw-r--r--CmdLine/Usage.hs8
3 files changed, 14 insertions, 9 deletions
diff --git a/CmdLine/GitAnnex.hs b/CmdLine/GitAnnex.hs
index 80ee876ff..5e37a885a 100644
--- a/CmdLine/GitAnnex.hs
+++ b/CmdLine/GitAnnex.hs
@@ -19,6 +19,7 @@ import qualified Command.Add
import qualified Command.Unannex
import qualified Command.Fsck
{-
+import qualified Command.Help
import qualified Command.Drop
import qualified Command.Move
import qualified Command.Copy
@@ -97,7 +98,6 @@ import qualified Command.Proxy
import qualified Command.DiffDriver
import qualified Command.Undo
import qualified Command.Version
-import qualified Command.Help
#ifdef WITH_ASSISTANT
import qualified Command.Watch
import qualified Command.Assistant
@@ -124,6 +124,7 @@ cmds =
[ Command.Add.cmd
, Command.Fsck.cmd
{-
+ , Command.Help.cmd
, Command.Get.cmd
, Command.Drop.cmd
, Command.Move.cmd
@@ -204,7 +205,6 @@ cmds =
, Command.DiffDriver.cmd
, Command.Undo.cmd
, Command.Version.cmd
- , Command.Help.cmd
#ifdef WITH_ASSISTANT
, Command.Watch.cmd
, Command.Assistant.cmd
@@ -224,9 +224,6 @@ cmds =
-}
]
-header :: String
-header = "git-annex command [option ...]"
-
run :: [String] -> IO ()
run args = do
#ifdef WITH_EKG
@@ -234,7 +231,9 @@ run args = do
#endif
go envmodes
where
- go [] = dispatch True args cmds gitAnnexOptions [] header Git.CurrentRepo.get
+ go [] = dispatch True args cmds gitAnnexOptions [] Git.CurrentRepo.get
+ "git-annex"
+ "manage files with git, without checking their contents in"
go ((v, a):rest) = maybe (go rest) a =<< getEnv v
envmodes =
[ (sshOptionsEnv, runSshOptions args)
diff --git a/CmdLine/GitAnnexShell.hs b/CmdLine/GitAnnexShell.hs
index fca37790b..bda4f7907 100644
--- a/CmdLine/GitAnnexShell.hs
+++ b/CmdLine/GitAnnexShell.hs
@@ -101,7 +101,9 @@ builtin cmd dir params = do
let (params', fieldparams, opts) = partitionParams params
rsyncopts = ("RsyncOptions", unwords opts)
fields = rsyncopts : filter checkField (parseFields fieldparams)
- dispatch False (cmd : params') cmds options fields header mkrepo
+ dispatch False (cmd : params') cmds options fields mkrepo
+ "git-annex-shell"
+ "Restricted login shell for git-annex only SSH access"
where
mkrepo = do
r <- Git.Construct.repoAbsPath dir >>= Git.Construct.fromAbsPath
diff --git a/CmdLine/Usage.hs b/CmdLine/Usage.hs
index 0b1cade05..a6cc90a71 100644
--- a/CmdLine/Usage.hs
+++ b/CmdLine/Usage.hs
@@ -13,9 +13,12 @@ import Types.Command
usageMessage :: String -> String
usageMessage s = "Usage: " ++ s
-{- Usage message with lists of commands by section. -}
usage :: String -> [Command] -> String
-usage header cmds = unlines $ usageMessage header : concatMap go [minBound..]
+usage header cmds = unlines $ usageMessage header : commandList cmds
+
+{- Commands listed by section, with breif usage and description. -}
+commandList :: [Command] -> [String]
+commandList cmds = concatMap go [minBound..]
where
go section
| null cs = []
@@ -39,6 +42,7 @@ usage header cmds = unlines $ usageMessage header : concatMap go [minBound..]
longest f = foldl max 0 $ map (length . f) cmds
scmds = sort cmds
+
{- Descriptions of params used in usage messages. -}
paramPaths :: String
paramPaths = paramRepeating paramPath -- most often used