module Args

open Argu
open Common

type private CLIArguments =
  | Browser of string
  | Tag of string
  | TestType of string
  with
    interface IArgParserTemplate with
      member s.Usage =
        match s with
        | Browser _ -> "specicfy a browser (Chrome Firefox IE)."
        | Tag _ -> "specify tag (All Misc etc)."
        | TestType _ -> "specify testType (All Smoke Full UnderDevelopment)."

let parse cliargs =
  let parser = ArgumentParser.Create<CLIArguments>()
  let results = parser.Parse(cliargs)

  {
    Browser = results.PostProcessResult (<@ Browser @>, fromString<canopy.types.BrowserStartMode>)
    Tag = results.PostProcessResult (<@ Tag @>, fromString<Tag>)
    TestType = results.PostProcessResult (<@ TestType @>, fromString<TestType>)
  }

module Args

open Argu
open Common

type private CLIArguments =
  | Browser of string
  | Tag of string
  | TestType of string
  with
    interface IArgParserTemplate with
      member s.Usage =
        match s with
        | Browser _ -> "specicfy a browser (Chrome Firefox IE)."
        | Tag _ -> "specify tag (All Misc etc)."
        | TestType _ -> "specify testType (All Smoke Full UnderDevelopment)."

let parse cliargs =
  let parser = ArgumentParser.Create<CLIArguments>()
  let results = parser.Parse(cliargs, errorHandler=ProcessExiter())

  {
    Browser = defaultArg (results.TryPostProcessResult (<@ Browser @>, fromString<canopy.types.BrowserStartMode>)) canopy.types.BrowserStartMode.Chrome
    Tag = defaultArg (results.TryPostProcessResult (<@ Tag @>, fromString<Tag>)) Tag.All
    TestType = defaultArg (results.TryPostProcessResult (<@ TestType @>, fromString<TestType>)) TestType.Smoke
  }

Make argument handling a little friendlier
Make argument handling a little friendlier

Default to printing usage and exiting if --help passed, instead of
throwing an exception. Also provide default arguments for all the
available options, so that running the program with no args does
something sensible as a default.
