Connected Devices: Added sync feature

This commit is contained in:
Ultradesu
2026-07-24 00:54:27 +03:00
parent 7fe6ddfe05
commit adbb76b031
13 changed files with 3095 additions and 16 deletions
+15
View File
@@ -27,6 +27,8 @@ pub enum Command {
Import(String),
/// `:open frid://...` — open a shared federation content link.
Open(String),
/// `:connect frid://i/...` — pair this client with a trusted device.
ConnectInvite(String),
/// `:volume 40` (also `:vol`) — set the volume precisely.
Volume(u8),
/// `:seek +30` / `:seek -10` — relative seek in seconds.
@@ -91,6 +93,15 @@ pub fn parse(input: &str) -> Parsed {
_ => Parsed::Invalid("usage: :open frid://<content_id>".to_string()),
}
}
"connect" => {
let value = input.trim_start().split_once(char::is_whitespace);
match value.map(|(_, rest)| rest.trim()) {
Some(value) if !value.is_empty() => {
Parsed::Command(Command::ConnectInvite(value.into()))
}
_ => Parsed::Invalid("usage: :connect frid://i/<invite>".to_string()),
}
}
"volume" | "vol" => match arg.and_then(|a| a.parse::<u8>().ok()) {
Some(value) if value <= 100 => Parsed::Command(Command::Volume(value)),
_ => Parsed::Invalid("usage: :volume 0-100".to_string()),
@@ -182,6 +193,10 @@ mod tests {
);
assert!(matches!(parse("import"), Parsed::Invalid(_)));
assert!(matches!(parse("open"), Parsed::Invalid(_)));
assert_eq!(
parse("connect frid://i/abcd"),
Parsed::Command(Command::ConnectInvite("frid://i/abcd".to_string()))
);
assert_eq!(parse("volume 40"), Parsed::Command(Command::Volume(40)));
assert_eq!(parse("vol 0"), Parsed::Command(Command::Volume(0)));
assert_eq!(parse("shuffle"), Parsed::Command(Command::Shuffle));