Skip to content

feat: add --watch to build command #29

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

jonathanpwang
Copy link

@jonathanpwang jonathanpwang commented Apr 18, 2025

Watches by polling the api until a final status.
Prints out logs if ends in error.

Written with Zed Agent

Example stdout:

Build request sent successfully: 9d7f4005-bcc5-472c-bf64-ccd87e927fde
Watching build status...
[2025-04-17 19:08:47] Build status: not_ready
[2025-04-17 19:08:52] Build status: processing
[2025-04-17 19:08:57] Build status: processing
[2025-04-17 19:09:03] Build status: processing
[2025-04-17 19:09:08] Build status: processing
[2025-04-17 19:09:13] Build status: processing
[2025-04-17 19:09:19] Build status: processing
[2025-04-17 19:09:24] Build status: processing
[2025-04-17 19:09:29] Build status: processing
[2025-04-17 19:09:35] Build status: processing
[2025-04-17 19:09:40] Build status: processing
[2025-04-17 19:09:46] Build status: processing
[2025-04-17 19:09:51] Build status: processing
[2025-04-17 19:09:56] Build status: processing
[2025-04-17 19:10:02] Build status: processing
[2025-04-17 19:10:07] Build status: processing
[2025-04-17 19:10:13] Build status: processing
[2025-04-17 19:10:18] Build status: processing
[2025-04-17 19:10:23] Build status: processing
[2025-04-17 19:10:29] Build status: processing
[2025-04-17 19:10:34] Build status: processing
[2025-04-17 19:10:40] Build status: processing
[2025-04-17 19:10:45] Build status: processing
[2025-04-17 19:10:50] Build status: processing
[2025-04-17 19:10:56] Build status: ready
Build completed successfully!

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new --watch flag to the build command that polls the API until the build reaches a final state and prints logs if an error occurs.

  • Added a --watch option in BuildArgs to enable watching build progress
  • Introduced helper functions (make_api_request, get_program_status, fetch_logs, watch_build_status, and fetch_and_print_logs) to support the watch functionality
  • Updated Cargo.toml to include the chrono dependency for timestamp formatting

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/commands/build.rs Added CLI flag --watch and related functionality for polling
Cargo.toml Added chrono dependency for date/time formatting

fn check_build_status(program_id: String) -> Result<()> {
println!("Checking build status for program ID: {}", program_id);

let status = get_program_status(&program_id)?;
Copy link
Preview

Copilot AI Apr 18, 2025

Choose a reason for hiding this comment

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

Consider extracting and printing only the specific build status field (e.g. status["status"]) instead of the full JSON object to ensure consistency with the output in watch_build_status.

Suggested change
let status = get_program_status(&program_id)?;
let status_json = get_program_status(&program_id)?;
let status = status_json
.get("status")
.and_then(|s| s.as_str())
.unwrap_or("unknown");

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant