Files
puregym-unofficial-dotnet/PureGym.App/Sessions.fs
Smaug123 66b44471d5
Some checks failed
ci/woodpecker/push/all-checks-complete Pipeline is pending
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/pr/build Pipeline failed
ci/woodpecker/pr/all-checks-complete unknown status
Rename
2023-12-28 20:10:56 +00:00

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
}