This patch moves the formatting of the command list to Cluster.hs and
enhances it with separator messages between the steps.
, applySolution
, printSolution
, printSolutionLine
+ , formatCmds
, printNodes
-- * Balacing functions
, checkMove
pmlen nstr c moves,
cmds)
+formatCmds :: [[String]] -> String
+formatCmds cmd_strs =
+ unlines $ map (" echo " ++) $
+ concat $ map (\(a, b) ->
+ (printf "step %d" (a::Int)):(map ("gnt-instance" ++) b)) $
+ zip [1..] cmd_strs
+
{-| Converts a solution to string format -}
printSolution :: InstanceList
-> [(Int, String)]
do
putStrLn ""
putStrLn "Commands to run to reach the above solution:"
- putStr $ unlines $ map (" echo gnt-instance " ++)
- $ concat $ reverse cmd_strs
+ putStr . Cluster.formatCmds . reverse $ cmd_strs
when (optShowNodes opts) $
do
let (orig_mem, orig_disk) = Cluster.totalResources nl
do
putStrLn ""
putStrLn "Commands to run to reach the above solution:"
- putStr $ unlines $ map (" echo gnt-instance " ++) $ concat cmd_strs
+ putStr . Cluster.formatCmds . reverse $ cmd_strs
+
when (optShowNodes opts) $
do
let (orig_mem, orig_disk) = Cluster.totalResources nl