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

definition:
 
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:
 no demanded arguments
deterministic:
 deterministic operation
documentation:
 
Process the actual command line arguments and return the options
and the name of the main program.
failfree:
 <FAILING>
indeterministic:
 referentially transparent operation
infix:
 no fixity defined
iotype:
 {(_,_) |-> _}
name:
 processOptions
precedence:
 no precedence defined
result-values:
 _
signature:
 String -> [String] -> Prelude.IO (Options, [String])
solution-complete:
 operation might suspend on free variables
terminating:
 possibly non-terminating
totally-defined:
 possibly non-reducible on same data term