Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve CLI UX #715

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
refactor!: audio command
  • Loading branch information
Saturn225 committed Nov 20, 2024
commit a4768d220f154a6ce8ab248ba3262b1101cc43e0
12 changes: 12 additions & 0 deletions screenpipe-audio/src/bin/screenpipe-audio-forever.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,22 @@ async fn main() -> Result<()> {
let devices = list_audio_devices().await?;

if args.list_audio_devices {
eprintln!(
"Warning: '--list-audio-devices' is deprecated and will be removed in a future release. Use 'screenpipe audio list' instead."
);
print_devices(&devices);
return Ok(());
}

if let Some(Command::Audio { subcommand }) = args.command {
match subcommand {
AudioCommand::List => {
print_devices(&devices);
return Ok(());
}
}
}

let devices = if args.audio_device.is_empty() {
vec![default_input_device()?, default_output_device()?]
} else {
Expand Down
28 changes: 28 additions & 0 deletions screenpipe-audio/src/bin/screenpipe-audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ struct Args {
deepgram_api_key: Option<String>,
}

#[derive(Subcommand, Debug)]
enum Command {
/// Audio-related commands
Audio {
#[clap(subcommand)]
subcommand: AudioCommand,
},
}

#[derive(Subcommand, Debug)]
enum AudioCommand {
/// List all available audio devices
List,
}

fn print_devices(devices: &[AudioDevice]) {
println!("Available audio devices:");
for device in devices.iter() {
Expand Down Expand Up @@ -65,10 +80,23 @@ async fn main() -> Result<()> {
let devices = list_audio_devices().await?;

if args.list_audio_devices {
eprintln!(
"Warning: '--list-audio-devices' is deprecated and will be removed in a future release. Use 'screenpipe audio list' instead."
);
print_devices(&devices);
return Ok(());
}

if let Some(Command::Audio { subcommand }) = args.command {
match subcommand {
AudioCommand::List => {
let devices = list_audio_devices().await?;
print_devices(&devices);
return Ok(());
}
}
}

let languages = args.language;

let deepgram_api_key = args.deepgram_api_key;
Expand Down
Loading