Commit 070b1109 authored by Don Stewart's avatar Don Stewart
Browse files

polish

parent 68759b73
...@@ -10,37 +10,45 @@ ...@@ -10,37 +10,45 @@
-- --
-- Entry point to the default cabal-install front-end. -- Entry point to the default cabal-install front-end.
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
module Main where
import Data.List (isSuffixOf) module Main where
import System.Environment (getArgs)
import Hackage.Types (Action (..), Option(..))
import Hackage.Setup (parseGlobalArgs, parsePackageArgs, configFromOptions)
import Hackage.Config (defaultConfigFile, loadConfig)
import Hackage.List (list) import Hackage.Types (Action (..), Option(..))
import Hackage.Install (install) import Hackage.Setup (parseGlobalArgs, parsePackageArgs, configFromOptions)
import Hackage.Info (info) import Hackage.Config (defaultConfigFile, loadConfig)
import Hackage.Update (update) import Hackage.List (list)
import Hackage.Fetch (fetch) import Hackage.Install (install)
import Hackage.Clean (clean) import Hackage.Info (info)
import Hackage.Update (update)
import Hackage.Fetch (fetch)
import Hackage.Clean (clean)
import Data.List (isSuffixOf)
import System.Environment (getArgs)
-- | Entry point
--
main :: IO () main :: IO ()
main = do args <- getArgs main = do
(action, flags, args) <- parseGlobalArgs args args <- getArgs
configFile <- case [f | OptConfigFile f <- flags] of (action, flags, args) <- parseGlobalArgs args
[] -> defaultConfigFile configFile <- case [f | OptConfigFile f <- flags] of
fs -> return $ last fs [] -> defaultConfigFile
conf0 <- loadConfig configFile fs -> return (last fs)
let config = configFromOptions conf0 flags
runCmd f = do (globalArgs, pkgs) <- parsePackageArgs action args conf0 <- loadConfig configFile
f config globalArgs pkgs
case action of let config = configFromOptions conf0 flags
InstallCmd -> runCmd install
InfoCmd -> runCmd info runCmd f = do (globalArgs, pkgs) <- parsePackageArgs action args
ListCmd -> list config args f config globalArgs pkgs
UpdateCmd -> update config
CleanCmd -> clean config case action of
FetchCmd -> fetch config args InstallCmd -> runCmd install
_ -> putStrLn "Unhandled command." InfoCmd -> runCmd info
ListCmd -> list config args
UpdateCmd -> update config
CleanCmd -> clean config
FetchCmd -> fetch config args
_ -> error "Unhandled command."
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment