lowfi/src/main.rs

89 lines
2.1 KiB
Rust
Raw Normal View History

//! An extremely simple lofi player.
#![warn(clippy::all, clippy::pedantic, clippy::nursery)]
2024-09-23 21:59:07 +02:00
use clap::{Parser, Subcommand};
mod play;
2024-09-25 18:11:42 +02:00
mod player;
2024-09-23 21:59:07 +02:00
mod tracks;
#[allow(clippy::all, clippy::pedantic, clippy::nursery, clippy::restriction)]
mod scrape;
2024-09-23 21:59:07 +02:00
/// An extremely simple lofi player.
#[derive(Parser)]
2024-10-02 14:30:55 +02:00
#[command(about, version)]
#[allow(
clippy::struct_excessive_bools,
reason = "señor clippy, i assure you this is not a state machine"
)]
2024-09-23 21:59:07 +02:00
struct Args {
2025-02-26 14:45:02 +01:00
/// Use an alternate terminal screen.
2024-10-02 00:27:18 +02:00
#[clap(long, short)]
alternate: bool,
2025-02-26 14:45:02 +01:00
/// Hide the bottom control bar.
2024-10-06 09:36:06 +02:00
#[clap(long, short)]
minimalist: bool,
2025-02-26 14:45:02 +01:00
/// Exclude borders in UI.
2025-02-09 15:38:33 +01:00
#[clap(long, short)]
2025-02-11 19:20:44 +01:00
borderless: bool,
2025-02-09 15:38:33 +01:00
2025-02-26 14:45:02 +01:00
/// Start lowfi paused.
2024-10-07 14:39:08 +02:00
#[clap(long, short)]
paused: bool,
2025-02-26 14:45:02 +01:00
/// Include ALSA & other logs.
2024-10-07 21:32:57 +02:00
#[clap(long, short)]
debug: bool,
2025-02-26 14:45:02 +01:00
/// Width of the player, from 0 to 32.
#[clap(long, short, default_value_t = 3)]
width: usize,
2025-02-26 14:45:02 +01:00
/// Use a custom track list
#[clap(long, short, alias = "list", short_alias = 'l')]
2025-02-26 14:45:02 +01:00
tracklist: Option<String>,
/// The command that was ran.
/// This is [None] if no command was specified.
2024-09-23 21:59:07 +02:00
#[command(subcommand)]
2024-09-26 16:13:40 +02:00
command: Option<Commands>,
2024-09-23 21:59:07 +02:00
}
/// Defines all of the extra commands lowfi can run.
2024-09-23 21:59:07 +02:00
#[derive(Subcommand)]
enum Commands {
2024-09-25 23:54:55 +02:00
/// Scrapes the lofi girl website file server for files.
Scrape {
2024-10-01 23:42:04 +02:00
/// The file extension to search for, defaults to mp3.
2024-09-25 23:54:55 +02:00
#[clap(long, short, default_value = "mp3")]
2024-10-01 23:42:04 +02:00
extension: String,
2024-09-25 23:54:55 +02:00
/// Whether to include the full HTTP URL or just the distinguishing part.
#[clap(long, short)]
include_full: bool,
},
2024-09-23 21:59:07 +02:00
}
#[tokio::main]
async fn main() -> eyre::Result<()> {
2025-02-09 15:58:08 +01:00
#[cfg(target_os = "android")]
compile_error!("Android Audio API not supported due to threading shenanigans");
2024-09-23 21:59:07 +02:00
let cli = Args::parse();
2024-09-26 16:13:40 +02:00
if let Some(command) = cli.command {
match command {
Commands::Scrape {
2024-10-01 23:42:04 +02:00
extension,
2024-09-26 16:13:40 +02:00
include_full,
2024-10-01 23:42:04 +02:00
} => scrape::scrape(extension, include_full).await,
2024-09-26 16:13:40 +02:00
}
} else {
play::play(cli).await
2024-09-23 21:59:07 +02:00
}
2024-09-25 18:11:42 +02:00
}