Revision f3d53161
b/hail.hs | ||
---|---|---|
27 | 27 |
|
28 | 28 |
import Data.List |
29 | 29 |
import Data.Function |
30 |
import Data.Maybe (isJust, fromJust) |
|
30 | 31 |
import Monad |
31 | 32 |
import System |
32 | 33 |
import System.IO |
... | ... | |
44 | 45 |
|
45 | 46 |
-- | Options list and functions |
46 | 47 |
options :: [OptType] |
47 |
options = [oShowVer, oShowHelp] |
|
48 |
options = [oPrintNodes, oShowVer, oShowHelp]
|
|
48 | 49 |
|
49 | 50 |
processResults :: (Monad m) => Cluster.AllocSolution -> m (String, [Node.Node]) |
50 | 51 |
processResults (fstats, successes, sols) = |
... | ... | |
71 | 72 |
main :: IO () |
72 | 73 |
main = do |
73 | 74 |
cmd_args <- System.getArgs |
74 |
(_, args) <- parseOpts cmd_args "hail" options
|
|
75 |
(opts, args) <- parseOpts cmd_args "hail" options
|
|
75 | 76 |
|
76 | 77 |
when (null args) $ do |
77 | 78 |
hPutStrLn stderr "Error: this program needs an input file." |
78 | 79 |
exitWith $ ExitFailure 1 |
79 | 80 |
|
80 | 81 |
let input_file = head args |
82 |
shownodes = optShowNodes opts |
|
81 | 83 |
input_data <- readFile input_file |
82 | 84 |
|
83 | 85 |
request <- case (parseData input_data) of |
... | ... | |
86 | 88 |
exitWith $ ExitFailure 1 |
87 | 89 |
Ok rq -> return rq |
88 | 90 |
|
89 |
let Request _ _ _ _ csf = request |
|
90 |
sols = processRequest request >>= processResults |
|
91 |
let Request _ nl _ _ csf = request |
|
92 |
|
|
93 |
when (isJust shownodes) $ do |
|
94 |
hPutStrLn stderr "Initial cluster status:" |
|
95 |
hPutStrLn stderr $ Cluster.printNodes nl (fromJust shownodes) |
|
96 |
|
|
97 |
let sols = processRequest request >>= processResults |
|
91 | 98 |
let (ok, info, rn) = |
92 | 99 |
case sols of |
93 | 100 |
Ok (ginfo, sn) -> (True, "Request successful: " ++ ginfo, |
Also available in: Unified diff