Skip to content

Commit 95872f4

Browse files
committed
Sync event RPC changes
Mirror btcmap-api changes: expose --cron-schedule on create-event, and add --include-past and --include-deleted flags to get-events to match the new RPC params.
1 parent b42287a commit 95872f4

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

src/command/event.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ pub struct CreateEventArgs {
2121
pub starts_at: Option<String>,
2222
#[arg(long = "ends-at")]
2323
pub ends_at: Option<String>,
24+
#[arg(long = "cron-schedule")]
25+
pub cron_schedule: Option<String>,
2426
}
2527

2628
pub fn create_event(args: &CreateEventArgs) -> Result<()> {
@@ -30,13 +32,25 @@ pub fn create_event(args: &CreateEventArgs) -> Result<()> {
3032
"name": args.name,
3133
"website": args.website,
3234
"starts_at": args.starts_at,
33-
"ends_at": args.ends_at
35+
"ends_at": args.ends_at,
36+
"cron_schedule": args.cron_schedule,
3437
});
3538
rpc::call("create_event", params)?.print()
3639
}
3740

38-
pub fn get_events() -> Result<()> {
39-
rpc::call("get_events", Value::Object(Map::new()))?.print()
41+
#[derive(Args)]
42+
pub struct GetEventsArgs {
43+
#[arg(long)]
44+
pub include_past: bool,
45+
#[arg(long)]
46+
pub include_deleted: bool,
47+
}
48+
49+
pub fn get_events(args: &GetEventsArgs) -> Result<()> {
50+
let mut params = Map::new();
51+
params.insert("include_past".into(), Value::Bool(args.include_past));
52+
params.insert("include_deleted".into(), Value::Bool(args.include_deleted));
53+
rpc::call("get_events", Value::Object(params))?.print()
4054
}
4155

4256
#[derive(Args)]

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ mod sections {
123123
pub enum Event {
124124
CreateEvent(command::event::CreateEventArgs),
125125
/// Get all events
126-
GetEvents,
126+
GetEvents(command::event::GetEventsArgs),
127127
/// Get event by id
128128
GetEvent(command::event::GetEventArgs),
129129
/// Delete event by id
@@ -365,7 +365,7 @@ fn dispatch(section: &str, sub_matches: &ArgMatches) -> Result<()> {
365365
},
366366
"event" => match sections::Event::from_arg_matches(sub_matches)? {
367367
sections::Event::CreateEvent(args) => command::event::create_event(&args),
368-
sections::Event::GetEvents => command::event::get_events(),
368+
sections::Event::GetEvents(args) => command::event::get_events(&args),
369369
sections::Event::GetEvent(args) => command::event::get_event(&args),
370370
sections::Event::DeleteEvent(args) => command::event::delete_event(&args),
371371
},

0 commit comments

Comments
 (0)