1. Tobias Dammers
  2. hpaco

Commits

Tobias Dammers  committed 5cdd352

Added -O option

  • Participants
  • Parent commits c2790b6
  • Branches master
  • Tags 0.10.0

Comments (0)

Files changed (2)

File CommandArgs.hs

View file
 
 data CommandArgs = CommandArgs { caInputFiles :: [FilePath]
                                , caTemplateName :: Maybe String
+                               , caOptimizationLevel :: Int
                                , caOutputFormat :: OutputFormat
                                , caIncludeExtension :: Maybe String
                                , caPhpPretty :: Bool
                              &= name "template-name"
                              &= help "Template name used in output"
                              &= explicit
+                         , caOptimizationLevel = def
+                             &= name "O"
+                             &= help "Optimization level (currently 0 and 1 supported)"
+                             &= explicit
                          , caIncludeExtension = def
                              &= name "include-ext"
                              &= help "Extension to append to included templates"

File Main.hs

View file
         src' = if null rundata
                     then src
                     else pre ++ src ++ post
+        opt = case caOptimizationLevel cmdargs of
+                1 -> optimize
+                otherwise -> id
     ast <- reader src'
     case caOutputFormat cmdargs of
-        RunInterpreted -> runInterpreted (optimize ast) cmdargs templateName >> return "\n"
-        otherwise -> return . write . optimize $ ast
+        RunInterpreted -> runInterpreted (opt ast) cmdargs templateName >> return "\n"
+        otherwise -> return . write . opt $ ast
     where runInterpreted ast cmdargs templateName =
             let opts = Run.defaultOptions
                         { Run.roTemplateName = templateName `fromMaybe` (caTemplateName cmdargs)