50 lines
1.4 KiB
Forth
50 lines
1.4 KiB
Forth
namespace PureGym.App
|
|
|
|
open Argu
|
|
open PureGym
|
|
open System
|
|
|
|
type SessionsArgsFragment =
|
|
| [<Mandatory ; EqualsAssignmentOrSpaced>] From_Date of string
|
|
| [<Mandatory ; EqualsAssignmentOrSpaced>] To_Date of string
|
|
|
|
interface IArgParserTemplate with
|
|
member s.Usage =
|
|
match s with
|
|
| From_Date _ -> "start of date range (inclusive) for query, which needs to parse as a DateTime"
|
|
| To_Date _ -> "end of date range (inclusive) for query, which needs to parse as a DateTime"
|
|
|
|
type SessionsArgs =
|
|
{
|
|
Creds : Auth
|
|
FromDate : DateOnly
|
|
ToDate : DateOnly
|
|
}
|
|
|
|
static member Parse
|
|
(auth : Auth)
|
|
(args : SessionsArgsFragment ParseResults)
|
|
: Result<SessionsArgs, ArguParseException>
|
|
=
|
|
let fromDate = args.GetResult SessionsArgsFragment.From_Date
|
|
let toDate = args.GetResult SessionsArgsFragment.To_Date
|
|
|
|
{
|
|
Creds = auth
|
|
FromDate = DateOnly.Parse fromDate
|
|
ToDate = DateOnly.Parse toDate
|
|
}
|
|
|> Ok
|
|
|
|
[<RequireQualifiedAccess>]
|
|
module Sessions =
|
|
|
|
let run (args : SessionsArgs) =
|
|
task {
|
|
let! client = Api.make args.Creds
|
|
let! activity = client.GetSessions (args.FromDate, args.ToDate)
|
|
|
|
System.Console.WriteLine (string<Sessions> activity)
|
|
return 0
|
|
}
|