MCPcopy Create free account
hub / github.com/BigBoot/AutoKuma / handle

Function handle

kuma-cli/src/notification.rs:26–88  ·  view source on GitHub ↗
(command: &Option<Command>, config: &Config, cli: &Cli)

Source from the content-addressed store, hash-verified

24}
25
26pub(crate) async fn handle(command: &Option<Command>, config: &Config, cli: &Cli) {
27 match command {
28 Some(Command::Add { file }) => connect(config, cli)
29 .await
30 .pipe_borrow(|client| {
31 load_files(file, cli).then(|values| {
32 join_all(
33 values
34 .into_iter()
35 .map(|value| client.add_notification(value)),
36 )
37 })
38 })
39 .await
40 .into_iter()
41 .collect::<Result<Vec<_>>>()
42 .map(|result| result.into_iter().collect_or_unwrap())
43 .print_result(cli),
44
45 Some(Command::Edit { file }) => connect(config, cli)
46 .await
47 .pipe_borrow(|client| {
48 load_files(file, cli).then(|values| {
49 join_all(
50 values
51 .into_iter()
52 .map(|value| client.edit_notification(value)),
53 )
54 })
55 })
56 .await
57 .into_iter()
58 .collect::<Result<Vec<_>>>()
59 .map(|result| result.into_iter().collect_or_unwrap())
60 .print_result(cli),
61
62 Some(Command::Get { id }) => connect(config, cli)
63 .await
64 .pipe_borrow(|client| join_all(id.iter().map(|id| client.get_notification(*id))))
65 .await
66 .into_iter()
67 .collect::<Result<Vec<_>>>()
68 .map(|result| result.into_iter().collect_or_unwrap())
69 .print_result(cli),
70
71 Some(Command::Delete { id }) => connect(config, cli)
72 .await
73 .pipe_borrow(|client| join_all(id.iter().map(|id| client.delete_notification(*id))))
74 .await
75 .into_iter()
76 .collect::<Result<Vec<_>>>()
77 .map(|result| result.into_iter().collect_or_unwrap())
78 .print_result(cli),
79
80 Some(Command::List {}) => connect(config, cli)
81 .await
82 .get_notifications()
83 .await

Callers

nothing calls this directly

Calls 10

connectFunction · 0.85
load_filesFunction · 0.85
print_resultMethod · 0.80
add_notificationMethod · 0.80
collect_or_unwrapMethod · 0.80
edit_notificationMethod · 0.80
iterMethod · 0.80
get_notificationMethod · 0.80
delete_notificationMethod · 0.80
get_notificationsMethod · 0.45

Tested by

no test coverage detected