order commands in usage by name
This commit is contained in:
parent
db6b4cdfcf
commit
990fcad978
2 changed files with 11 additions and 1 deletions
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
module Types.Command where
|
module Types.Command where
|
||||||
|
|
||||||
|
import Data.Ord
|
||||||
|
|
||||||
import Types
|
import Types
|
||||||
|
|
||||||
{- A command runs in these stages.
|
{- A command runs in these stages.
|
||||||
|
@ -46,3 +48,10 @@ data Command = Command
|
||||||
{- CommandCheck functions can be compared using their unique id. -}
|
{- CommandCheck functions can be compared using their unique id. -}
|
||||||
instance Eq CommandCheck where
|
instance Eq CommandCheck where
|
||||||
a == b = idCheck a == idCheck b
|
a == b = idCheck a == idCheck b
|
||||||
|
|
||||||
|
instance Eq Command where
|
||||||
|
a == b = cmdname a == cmdname b
|
||||||
|
|
||||||
|
{- Order commands by name -}
|
||||||
|
instance Ord Command where
|
||||||
|
compare = comparing cmdname
|
||||||
|
|
3
Usage.hs
3
Usage.hs
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
module Usage where
|
module Usage where
|
||||||
|
|
||||||
|
import Common.Annex
|
||||||
import System.Console.GetOpt
|
import System.Console.GetOpt
|
||||||
|
|
||||||
import Types.Command
|
import Types.Command
|
||||||
|
@ -30,7 +31,7 @@ usage header cmds commonoptions = unlines $
|
||||||
alloptlines = filter (not . null) $
|
alloptlines = filter (not . null) $
|
||||||
lines $ usageInfo "" $
|
lines $ usageInfo "" $
|
||||||
concatMap cmdoptions cmds ++ commonoptions
|
concatMap cmdoptions cmds ++ commonoptions
|
||||||
(cmdlines, optlines) = go cmds alloptlines []
|
(cmdlines, optlines) = go (sort cmds) alloptlines []
|
||||||
go [] os ls = (ls, os)
|
go [] os ls = (ls, os)
|
||||||
go (c:cs) os ls = go cs os' (ls++(l:o))
|
go (c:cs) os ls = go cs os' (ls++(l:o))
|
||||||
where
|
where
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue