54 lines
1.2 KiB
Forth
54 lines
1.2 KiB
Forth
namespace PureGym.App
|
|
|
|
open System.Threading
|
|
open Argu
|
|
open PureGym
|
|
|
|
type AllGymsArgsFragment =
|
|
| [<Unique ; EqualsAssignmentOrSpaced>] Terse of bool
|
|
|
|
interface IArgParserTemplate with
|
|
member s.Usage =
|
|
match s with
|
|
| Terse _ -> "print only 'id,gym-name'"
|
|
|
|
type AllGymsArgs =
|
|
{
|
|
Creds : Auth
|
|
Terse : bool
|
|
}
|
|
|
|
static member Parse
|
|
(auth : Auth)
|
|
(args : AllGymsArgsFragment ParseResults)
|
|
: Result<AllGymsArgs, ArguParseException>
|
|
=
|
|
let terse =
|
|
match args.TryGetResult AllGymsArgsFragment.Terse with
|
|
| None -> false
|
|
| Some x -> x
|
|
|
|
{
|
|
Creds = auth
|
|
Terse = terse
|
|
}
|
|
|> Ok
|
|
|
|
[<RequireQualifiedAccess>]
|
|
module AllGyms =
|
|
|
|
let run (args : AllGymsArgs) =
|
|
task {
|
|
let! client = Api.makeWithoutRefresh CancellationToken.None args.Creds
|
|
let! s = client.GetGyms ()
|
|
|
|
if args.Terse then
|
|
for gym in s do
|
|
System.Console.WriteLine $"%i{gym.Id},%s{gym.Name}"
|
|
else
|
|
for gym in s do
|
|
System.Console.WriteLine (string<Gym> gym)
|
|
|
|
return 0
|
|
}
|