Permalink
Browse files

Enable --verbose for 'hackport list'

  • Loading branch information...
1 parent a08b0e7 commit 04af916b9fe5482a848abbb435fcd42cc45a765b @kolmodin kolmodin committed Sep 1, 2008
Showing with 25 additions and 6 deletions.
  1. +25 −6 Main.hs
View
31 Main.hs
@@ -42,21 +42,40 @@ import Cabal2Ebuild
-- List
-----------------------------------------------------------------------
-listCommand :: CommandUI ()
+data ListFlags = ListFlags {
+ listVerbosity :: Flag Verbosity
+ }
+
+instance Monoid ListFlags where
+ mempty = ListFlags {
+ listVerbosity = mempty
+ }
+ mappend a b = ListFlags {
+ listVerbosity = combine listVerbosity
+ }
+ where combine field = field a `mappend` field b
+
+defaultListFlags :: ListFlags
+defaultListFlags = ListFlags {
+ listVerbosity = Flag normal
+ }
+
+listCommand :: CommandUI ListFlags
listCommand = CommandUI {
commandName = "list",
commandSynopsis = "List packages",
commandDescription = Just $ \pname ->
"TODO: this is the commandDescription for listCommand\n",
commandUsage = usagePackages "list",
- commandDefaultFlags = (),
+ commandDefaultFlags = defaultListFlags,
commandOptions = \showOrParseArgs ->
- []
+ [ optionVerbosity listVerbosity (\v flags -> flags { listVerbosity = v })
+ ]
}
-listAction :: () -> [String] -> GlobalFlags -> IO ()
-listAction _ args globalFlags = do
- let verbose = normal -- fromFlag (globalVerbosity globalFlags)
+listAction :: ListFlags -> [String] -> GlobalFlags -> IO ()
+listAction flags args globalFlags = do
+ let verbose = fromFlag (listVerbosity flags)
portDirM = flagToMaybe (globalOverlayPath globalFlags)
overlay <-
case portDirM of

0 comments on commit 04af916

Please sign in to comment.