pub mod implementations;
pub mod printing;
pub mod utils;
#[cfg(test)]
mod smoke_tests;
use clap::{Subcommand, ValueEnum};
pub trait CommandHandler {
type Output;
async fn handle(
&self,
ctx: tarpc::context::Context,
client: mecomp_core::rpc::MusicPlayerClient,
) -> Self::Output;
}
#[derive(Debug, Subcommand)]
pub enum Command {
Ping,
#[clap(alias = "exit")]
Stop,
Library {
#[clap(subcommand)]
command: LibraryCommand,
},
Status {
#[clap(subcommand)]
command: StatusCommand,
},
State,
Current { target: CurrentTarget },
Rand { target: RandTarget },
#[clap(hide = true)]
Search {
target: SearchTarget,
query: String,
#[clap(default_value = "10")]
limit: u32,
},
Playback {
#[clap(subcommand)]
command: PlaybackCommand,
},
Queue {
#[clap(subcommand)]
command: QueueCommand,
},
Playlist {
#[clap(subcommand)]
command: PlaylistCommand,
},
Collection {
#[clap(subcommand)]
command: CollectionCommand,
},
Radio {
#[clap(subcommand)]
command: RadioCommand,
},
}
#[derive(Debug, Subcommand)]
pub enum LibraryCommand {
Rescan,
Analyze,
Recluster,
Brief,
Full,
Health,
List {
#[clap(long)]
full: bool,
target: LibraryListTarget,
},
Get {
target: LibraryGetTarget,
id: String,
},
}
#[derive(Debug, PartialEq, Eq, Clone, Copy, ValueEnum)]
pub enum LibraryListTarget {
Artists,
Albums,
Songs,
}
#[derive(Debug, PartialEq, Eq, Clone, Copy, ValueEnum)]
pub enum LibraryGetTarget {
Artist,
Album,
Song,
Playlist,
}
#[derive(Debug, PartialEq, Eq, Clone, Copy, ValueEnum)]
pub enum CurrentTarget {
Artist,
Album,
Song,
}
#[derive(Debug, PartialEq, Eq, Clone, Copy, ValueEnum)]
pub enum RandTarget {
Artist,
Album,
Song,
}
#[derive(Debug, PartialEq, Eq, Clone, Copy, ValueEnum)]
pub enum SearchTarget {
All,
Artist,
Album,
Song,
}
#[derive(Debug, Subcommand)]
pub enum StatusCommand {
Rescan,
Analyze,
Recluster,
}
#[derive(Debug, Subcommand)]
pub enum PlaybackCommand {
Toggle,
Play,
Pause,
Stop,
Restart,
Next,
Previous,
Seek {
#[clap(subcommand)]
command: SeekCommand,
},
Volume {
#[clap(subcommand)]
command: VolumeCommand,
},
Repeat {
mode: RepeatMode,
},
Shuffle,
}
#[derive(Debug, Subcommand)]
pub enum SeekCommand {
#[clap(alias = "f", alias = "+", alias = "ahead")]
Forward {
amount: f32,
},
#[clap(alias = "b", alias = "-", alias = "back")]
Backward {
amount: f32,
},
#[clap(alias = "a", alias = "=", alias = "to")]
Absolute {
position: f32,
},
}
#[derive(Debug, Subcommand)]
pub enum VolumeCommand {
Set {
volume: f32,
},
#[clap(alias = "up")]
Increase {
amount: f32,
},
#[clap(alias = "down")]
Decrease {
amount: f32,
},
Mute,
Unmute,
}
#[derive(Debug, PartialEq, Eq, Clone, Copy, ValueEnum)]
pub enum RepeatMode {
None,
Once,
Continuous,
}
impl From<RepeatMode> for mecomp_core::state::RepeatMode {
fn from(mode: RepeatMode) -> Self {
match mode {
RepeatMode::None => Self::None,
RepeatMode::Once => Self::Once,
RepeatMode::Continuous => Self::Continuous,
}
}
}
#[derive(Debug, Subcommand)]
pub enum QueueCommand {
Clear,
List,
Add {
target: QueueAddTarget,
id: String,
},
Remove {
start: usize,
end: usize,
},
Set {
index: usize,
},
Pipe,
}
#[derive(Debug, PartialEq, Eq, Clone, Copy, ValueEnum)]
pub enum QueueAddTarget {
Artist,
Album,
Song,
Playlist,
Collection,
}
#[derive(Debug, Subcommand)]
pub enum PlaylistCommand {
List,
Get {
method: PlaylistGetMethod,
target: String,
},
Create {
name: String,
},
Delete {
id: String,
},
Add {
#[clap(subcommand)]
command: PlaylistAddCommand,
},
Remove {
id: String,
item_ids: Vec<String>,
},
}
#[derive(Debug, PartialEq, Eq, Clone, Copy, ValueEnum)]
pub enum PlaylistGetMethod {
Id,
Name,
}
#[derive(Debug, Subcommand)]
pub enum PlaylistAddCommand {
Artist {
id: String,
artist_id: String,
},
Album {
id: String,
album_id: String,
},
Song {
id: String,
song_ids: Vec<String>,
},
Pipe {
id: String,
},
}
#[derive(Debug, Subcommand)]
pub enum CollectionCommand {
List,
Get {
id: String,
},
Recluster,
Freeze {
id: String,
name: String,
},
}
#[derive(Debug, Subcommand)]
pub enum RadioCommand {
Song {
id: String,
n: u32,
},
Artist {
id: String,
n: u32,
},
Album {
id: String,
n: u32,
},
Playlist {
id: String,
n: u32,
},
Pipe {
n: u32,
},
}