namespace PureGym.App open Argu open PureGym type LookupGymArgsFragment = | [] Gym_Id of int | [] Gym_Name of string interface IArgParserTemplate with member s.Usage = match s with | LookupGymArgsFragment.Gym_Id _ -> "ID of the gym to look up, according to PureGym's internal mapping" | LookupGymArgsFragment.Gym_Name _ -> "Name of a gym (best-guess fuzzy matching)" type LookupGymArgs = { Creds : Auth Gym : GymSelector } static member Parse (auth : Auth) (args : LookupGymArgsFragment ParseResults) : Result = let gym = match args.TryGetResult LookupGymArgsFragment.Gym_Id, args.TryGetResult LookupGymArgsFragment.Gym_Name with | Some _, Some _ -> failwith "--gym-id and --gym-name are mutually exclusive" | None, None -> System.Console.Error.WriteLine "No gym ID given and no gym named; assuming the user's home gym" GymSelector.Home | Some id, None -> GymSelector.Id id | None, Some name -> GymSelector.Name name { Creds = auth Gym = gym } |> Ok [] module LookupGym = let run (args : LookupGymArgs) = task { let! client = Api.make args.Creds let! s = client.GetGym 19 System.Console.WriteLine (string s) return 0 }