CurryInfo: cpm-query-0.1.0 / CPM.Query.Options.processOptions

definition: Info
 
processOptions :: String -> [String] -> IO (Options,[String])
processOptions banner argv = do
  dfltoptions <- getDefaultOptions
  isterminal <- hIsTerminalDevice stdout
  let opts0 = dfltoptions { optColor = isterminal }
  let (funopts, args, opterrors) = getOpt Permute options argv
      opts1 = foldl (flip id) opts0 funopts
  unless (null opterrors)
         (putStr (unlines opterrors) >> printUsage >> exitWith 1)
  when (optHelp opts1) (printUsage >> exitWith 0)
  when (not (null (optGenFrom opts1)) && not (optGenerate opts1))
       (putStrLn "Superfluous file with generate data!" >> exitWith 1)
  let opts2 = -- Generate on the web server only if --remote is explicitly used:
              if optGenerate opts1 && "--remote" `notElem` argv
                then opts1 { optRemote = False }
                else opts1
  return (opts2, args)
 where
  printUsage = putStrLn (banner ++ "\n" ++ usageText)
demand: Info
 no demanded arguments
deterministic: Info
 deterministic operation
documentation: Info
 
Process the actual command line arguments and return the options
and the name of the main program.
failfree: Info
 <FAILING>
indeterministic: Info
 referentially transparent operation
infix: Info
 no fixity defined
iotype: Info
 {(_,_) |-> _}
name: Info
 processOptions
precedence: Info
 no precedence defined
result-values: Info
 _
signature: Info
 String -> [String] -> Prelude.IO (Options, [String])
solution-complete: Info
 operation might suspend on free variables
terminating: Info
 possibly non-terminating
totally-defined: Info
 possibly non-reducible on same data term