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

Refactor client #608

Merged
merged 6 commits into from
Feb 11, 2025
Merged
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
22 changes: 20 additions & 2 deletions pueue/src/bin/pueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use color_eyre::{
use pueue::client::{
cli::{CliArguments, Shell, SubCommand},
client::Client,
handle_command,
};
use pueue_lib::settings::Settings;

Expand Down Expand Up @@ -53,11 +54,28 @@ async fn main() -> Result<()> {
bail!("Couldn't find a configuration file. Did you start the daemon yet?");
}

// Determine the subcommand that has been called by the user.
// If no subcommand is given, we default to the `status` subcommand without any arguments.
let subcommand = opt.cmd.unwrap_or(SubCommand::Status {
json: false,
group: None,
query: Vec::new(),
});

// Only show version incompatibility warnings if we aren't supposed to output json.
let show_version_warning = match subcommand {
SubCommand::Status { json, .. } => !json,
SubCommand::Log { json, .. } => !json,
SubCommand::Group { json, .. } => !json,
_ => true,
};

// Create client to talk with the daemon and connect.
let mut client = Client::new(settings, opt)
let mut client = Client::new(settings, show_version_warning, &opt.color)
.await
.context("Failed to initialize client.")?;
client.start().await?;

handle_command(&mut client, subcommand).await?;

Ok(())
}
Expand Down
Loading
Loading