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

polish

parent 68759b73
......@@ -10,37 +10,45 @@
--
-- 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)
module Main where
import Hackage.List (list)
import Hackage.Install (install)
import Hackage.Info (info)
import Hackage.Update (update)
import Hackage.Fetch (fetch)
import Hackage.Clean (clean)
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)
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
(action, flags, args) <- parseGlobalArgs args
configFile <- case [f | OptConfigFile f <- flags] of
[] -> defaultConfigFile
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
ListCmd -> list config args
UpdateCmd -> update config
CleanCmd -> clean config
FetchCmd -> fetch config args
_ -> putStrLn "Unhandled command."
main = do
args <- getArgs
(action, flags, args) <- parseGlobalArgs args
configFile <- case [f | OptConfigFile f <- flags] of
[] -> defaultConfigFile
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
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