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

polish

parent 68759b73
......@@ -10,14 +10,12 @@
--
-- Entry point to the default cabal-install front-end.
-----------------------------------------------------------------------------
module Main where
import Data.List (isSuffixOf)
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.Install (install)
import Hackage.Info (info)
......@@ -25,17 +23,26 @@ 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 = do args <- getArgs
main = do
args <- getArgs
(action, flags, args) <- parseGlobalArgs args
configFile <- case [f | OptConfigFile f <- flags] of
[] -> defaultConfigFile
fs -> return $ last fs
fs -> return (last fs)
conf0 <- loadConfig configFile
let config = configFromOptions conf0 flags
runCmd f = do (globalArgs, pkgs) <- parsePackageArgs action args
f config globalArgs pkgs
case action of
InstallCmd -> runCmd install
InfoCmd -> runCmd info
......@@ -43,4 +50,5 @@ main = do args <- getArgs
UpdateCmd -> update config
CleanCmd -> clean config
FetchCmd -> fetch config args
_ -> putStrLn "Unhandled command."
_ -> 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