Skip to content
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
9 changes: 8 additions & 1 deletion crates/pebble/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,14 @@ impl RunContext {
}
}

/// Emit the highest-scoring ready tasks according to the default ranking.
/// Emits the highest-scoring ready tasks according to the default ranking.
///
/// # Errors
///
/// Returns an error in the following cases:
/// * The task graph cannot be loaded from the tasks directory.
/// * No ready tasks are found (returns a [`NotFoundError`]).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The documentation for this error condition is slightly inaccurate. The NotFoundError is only returned when not in JSON mode (ctx.json is false). In JSON mode, an empty list of tasks is returned successfully. The documentation should clarify this to avoid confusion for consumers of this function.

Suggested change
/// * No ready tasks are found (returns a [`NotFoundError`]).
/// * No ready tasks are found when not using JSON output (returns a [`NotFoundError`]).

/// * Serialization fails when outputting JSON.
pub fn run_next(ctx: &RunContext, limit: usize) -> Result<()> {
let graph = TaskGraph::load_from_dir(&ctx.tasks_dir)?;
let next_tasks = graph.get_next_tasks();
Expand Down
17 changes: 15 additions & 2 deletions crates/pebble/src/commands/listing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,12 @@ fn emit_task_list(ctx: &RunContext, graph: &TaskGraph, tasks: Vec<&TaskNode>) ->
Ok(())
}

/// List tasks using the default ordering, with optional filters.
/// Lists tasks using the default ordering, with optional filters.
///
/// # Errors
///
/// Returns an error if the task graph cannot be loaded from the tasks directory,
/// if the provided sort option is invalid, or if serialization fails when outputting JSON.
pub fn run_list(ctx: &RunContext, options: &ListOptions) -> Result<()> {
let graph = TaskGraph::load_from_dir(&ctx.tasks_dir)?;
let tasks = filter_list_tasks(&graph, options);
Expand All @@ -215,7 +220,15 @@ pub fn run_list(ctx: &RunContext, options: &ListOptions) -> Result<()> {
emit_task_list(ctx, &graph, tasks)
}

/// Search tasks by case-insensitive substring across title and body.
/// Searches tasks by case-insensitive substring across title and body.
///
/// # Errors
///
/// Returns an error in the following cases:
/// * The task graph cannot be loaded from the tasks directory.
/// * No matching tasks are found (returns a [`NotFoundError`]).
/// * The tasks cannot be ordered correctly.
/// * Serialization fails when outputting JSON.
pub fn run_search(ctx: &RunContext, query: &str) -> Result<()> {
let graph = TaskGraph::load_from_dir(&ctx.tasks_dir)?;
let needle = query.to_lowercase();
Expand Down