packages feed

multi-cabal-0.1.0.0: src/MultiCabal/Commands/Help.hs

{-# LANGUAGE FlexibleContexts #-}

{- |
Module      :  $Header$
Description :  A simple help command.
Author      :  Nils 'bash0r' Jonsson
Copyright   :  (c) 2015 Nils 'bash0r' Jonsson
License     :  MIT

Maintainer  :  aka.bash0r@gmail.com
Stability   :  unstable
Portability :  non-portable (Portability is untested.)

A simple help command.
-}
module MultiCabal.Commands.Help
( invokeExec
, invokeHelp
) where

import Control.Applicative
import Control.Monad

import Control.Command
import Control.Router

import MultiCabal.Instruction

invokeExec :: (Command Instruction, Router Instruction) => [String] -> IO ()
invokeExec [cmd] = case route availableCommands cmd of
    Just a  -> putStrLn (help a)
    Nothing -> putStrLn ("The command " ++ cmd ++ " does not exist.")
invokeExec _     = mapM_ putStrLn (fmap help availableCommands) >> putStrLn ""

invokeHelp :: String
invokeHelp =
    "multi-cabal help\n" ++
    "  shows a general help dialog\n" ++
    "multi-cabal help COMMAND\n" ++
    "  shows the specific help dialog of COMMAND"