Skip to content

Commit

Permalink
remove: status-format subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
Nukesor committed Feb 16, 2025
1 parent 60cbaa6 commit 0f71a10
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 59 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ Upon updating Pueue and restarting the daemon, the previous state will be wiped,
- Print incompatible version warning info as a log message instead of plain stdout input, which broke json outputs [#562](https://github.com/Nukesor/pueue/issues/562).
- Fixed `-d` daemon mode on Windows. [#344](https://github.com/Nukesor/pueue/issues/344)

### Remove

- `status-format` subcommand. This was a temporary workaround until the `status query` feature was finished, which is now the case.

## \[3.4.1\] - 2024-06-04

### Added
Expand Down
15 changes: 0 additions & 15 deletions pueue/src/client/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,21 +392,6 @@ https://github.com/Nukesor/pueue/issues/350#issue-1359083118"
group: Option<String>,
},

/// Accept a list or map of JSON pueue tasks via stdin and display it just
/// like \"pueue status\".
///
/// A simple example might look like this:
///
/// pueue status --json | jq -c '.tasks' | pueue format-status",
#[command(after_help = "DISCLAIMER:\n\
This command is a temporary workaround until a proper filtering language for \"status\" has
been implemented. It might be removed in the future.")]
FormatStatus {
#[arg(short, long)]
/// Only show tasks of a specific group
group: Option<String>,
},

/// Display the log output of finished tasks.
///
/// Only the last few lines will be shown by default.
Expand Down
3 changes: 1 addition & 2 deletions pueue/src/client/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ use send::send;
use shutdown::shutdown;
use start::start;
use stash::stash;
use state::{format_state, state};
use state::state;
use switch::switch;
use wait::wait;
pub use wait::WaitTargetStatus;
Expand Down Expand Up @@ -203,7 +203,6 @@ pub async fn handle_command(
} => enqueue(client, style, task_ids, group, all, delay_until).await,
SubCommand::Env { cmd } => env(client, style, cmd).await,
SubCommand::Follow { task_id, lines } => follow(client, style, task_id, lines).await,
SubCommand::FormatStatus { group } => format_state(client, style, group).await,
SubCommand::Group { cmd, json } => group(client, style, cmd, json).await,
SubCommand::Kill {
task_ids,
Expand Down
43 changes: 1 addition & 42 deletions pueue/src/client/commands/state/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use std::{
collections::BTreeMap,
io::{self, prelude::*},
};
use std::collections::BTreeMap;

use chrono::{DateTime, Local, LocalResult};
use pueue_lib::{
Expand Down Expand Up @@ -47,44 +44,6 @@ pub async fn state(
Ok(())
}

/// This function tries to read a map or list of JSON serialized [Task]s from `stdin`.
/// The tasks will then get deserialized and displayed as a normal `status` command.
/// The current group information is pulled from the daemon in a new `status` call.
pub async fn format_state(
client: &mut Client,
style: &OutputStyle,
group: Option<String>,
) -> Result<()> {
// Read the raw input to a buffer
let mut stdin = io::stdin();
let mut buffer = Vec::new();
stdin
.read_to_end(&mut buffer)
.context("Failed to read json from stdin.")?;

// Convert it to a valid utf8 stream. If this fails, it cannot be valid JSON.
let json = String::from_utf8(buffer).context("Failed to convert stdin input to UTF8")?;

// Try to deserialize the input as a map of tasks first.
// If this doesn't work, try a list of tasks.
let map_deserialize = serde_json::from_str::<BTreeMap<usize, Task>>(&json);

let tasks: Vec<Task> = if let Ok(map) = map_deserialize {
map.into_values().collect()
} else {
serde_json::from_str(&json).context("Failed to deserialize from JSON input.")?
};

let state = get_state(client)
.await
.context("Failed to get the current state from daemon")?;

let output = print_state(state, tasks, style, &client.settings, false, group, None)?;
print!("{output}");

Ok(())
}

/// Get the output for the state of the daemon in a nicely formatted table.
/// If there are multiple groups, each group with a task will have its own table.
///
Expand Down

0 comments on commit 0f71a10

Please sign in to comment.