-
Notifications
You must be signed in to change notification settings - Fork 283
Add --quiet flag to shuttle run #2130
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
dcodesdev
wants to merge
1
commit into
main
Choose a base branch
from
feat/shuttle-run-quiet
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+74
−44
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -1404,24 +1404,24 @@ impl Shuttle { | |||||||
| fs::write(path, archive).context("writing archive")?; | ||||||||
| Ok(()) | ||||||||
| } else if build_args.inner.docker { | ||||||||
| self.local_docker_build(project_args, &build_args.inner) | ||||||||
| self.local_docker_build(project_args, &build_args.inner, false) | ||||||||
| .await | ||||||||
| } else { | ||||||||
| self.local_build(&build_args.inner).await.map(|_| ()) | ||||||||
| self.local_build(&build_args.inner, false).await.map(|_| ()) | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| async fn local_build(&self, build_args: &BuildArgsShared) -> Result<BuiltService> { | ||||||||
| async fn local_build(&self, build_args: &BuildArgsShared, quiet: bool) -> Result<BuiltService> { | ||||||||
| let project_directory = self.ctx.project_directory(); | ||||||||
|
|
||||||||
| cargo_green_eprintln("Building", project_directory.display()); | ||||||||
| if !quiet { | ||||||||
| cargo_green_eprintln("Building", project_directory.display()); | ||||||||
| } | ||||||||
|
|
||||||||
| // TODO: hook up -q/--quiet flag | ||||||||
| let quiet = false; | ||||||||
| cargo_build(project_directory.to_owned(), build_args.release, quiet).await | ||||||||
| } | ||||||||
|
|
||||||||
| fn find_available_port(run_args: &mut RunArgs) { | ||||||||
| fn find_available_port(run_args: &mut RunArgs, quiet: bool) { | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Missing function documentation explaining the purpose of the new
Suggested change
Context Used: Context from Prompt To Fix With AIThis is a comment left during a code review.
Path: cargo-shuttle/src/lib.rs
Line: 1424:1424
Comment:
**style:** Missing function documentation explaining the purpose of the new `quiet` parameter
```suggestion
/// Finds an available port for the service, optionally suppressing port change messages
fn find_available_port(run_args: &mut RunArgs, quiet: bool) {
```
**Context Used:** Context from `dashboard` - Include comments explaining the purpose of functions, especially for new or complex functionality. ([source](https://app.greptile.com/review/custom-context?memory=fe8549ea-5239-4b00-a674-867d405455c8))
How can I resolve this? If you propose a fix, please make it concise. |
||||||||
| let original_port = run_args.port; | ||||||||
| for port in (run_args.port..=u16::MAX).step_by(10) { | ||||||||
| if !portpicker::is_free_tcp(port) { | ||||||||
|
|
@@ -1431,7 +1431,7 @@ impl Shuttle { | |||||||
| break; | ||||||||
| } | ||||||||
|
|
||||||||
| if run_args.port != original_port { | ||||||||
| if run_args.port != original_port && !quiet { | ||||||||
| eprintln!( | ||||||||
| "Port {} is already in use. Using port {}.", | ||||||||
| original_port, run_args.port, | ||||||||
|
|
@@ -1452,33 +1452,41 @@ impl Shuttle { | |||||||
|
|
||||||||
| // Handle bacon mode | ||||||||
| if run_args.build_args.bacon { | ||||||||
| cargo_green_eprintln( | ||||||||
| "Starting", | ||||||||
| format!("{} in watch mode using bacon", project_name), | ||||||||
| ); | ||||||||
| eprintln!(); | ||||||||
| if !run_args.quiet { | ||||||||
| cargo_green_eprintln( | ||||||||
| "Starting", | ||||||||
| format!("{} in watch mode using bacon", project_name), | ||||||||
| ); | ||||||||
| eprintln!(); | ||||||||
| } | ||||||||
| return bacon::run_bacon(project_directory).await; | ||||||||
| } | ||||||||
|
|
||||||||
| if run_args.build_args.docker { | ||||||||
| if run_args.build_args.docker && !run_args.quiet { | ||||||||
| eprintln!("WARN: Local run with --docker is EXPERIMENTAL. Please submit feedback on GitHub or Discord if you encounter issues."); | ||||||||
| } | ||||||||
|
|
||||||||
| let secrets = Shuttle::get_secrets(&run_args.secret_args, project_directory, true)? | ||||||||
| .unwrap_or_default(); | ||||||||
| Shuttle::find_available_port(&mut run_args); | ||||||||
|
|
||||||||
| let quiet = run_args.quiet; | ||||||||
| Shuttle::find_available_port(&mut run_args, quiet); | ||||||||
|
|
||||||||
| let s_re = if !run_args.build_args.docker { | ||||||||
| let service = self.local_build(&run_args.build_args).await?; | ||||||||
| let service = self | ||||||||
| .local_build(&run_args.build_args, run_args.quiet) | ||||||||
| .await?; | ||||||||
| trace!(path = ?service.executable_path, "runtime executable"); | ||||||||
| if let Some(warning) = check_and_warn_runtime_version(&service.executable_path).await? { | ||||||||
| eprint!("{}", warning); | ||||||||
| if !run_args.quiet { | ||||||||
| eprint!("{}", warning); | ||||||||
| } | ||||||||
| } | ||||||||
| let runtime_executable = service.executable_path.clone(); | ||||||||
|
|
||||||||
| Some((service, runtime_executable)) | ||||||||
| } else { | ||||||||
| self.local_docker_build(project_args, &run_args.build_args) | ||||||||
| self.local_docker_build(project_args, &run_args.build_args, run_args.quiet) | ||||||||
| .await?; | ||||||||
| None | ||||||||
| }; | ||||||||
|
|
@@ -1510,6 +1518,9 @@ impl Shuttle { | |||||||
| ("SHUTTLE_HEALTHZ_PORT", healthz_port.to_string()), | ||||||||
| ("SHUTTLE_API", format!("http://127.0.0.1:{}", api_port)), | ||||||||
| ]; | ||||||||
| if run_args.quiet { | ||||||||
| envs.push(("SHUTTLE_QUIET", "true".to_owned())); | ||||||||
| } | ||||||||
| // Use a nice debugging tracing level if user does not provide their own | ||||||||
| if debug && std::env::var("RUST_LOG").is_err() { | ||||||||
| envs.push(("RUST_LOG", "info,shuttle=trace,reqwest=debug".to_owned())); | ||||||||
|
|
@@ -1521,12 +1532,14 @@ impl Shuttle { | |||||||
| let name = format!("shuttle-run-{project_name}"); | ||||||||
| let mut child = if run_args.build_args.docker { | ||||||||
| let image = format!("shuttle-build-{project_name}"); | ||||||||
| eprintln!(); | ||||||||
| cargo_green_eprintln( | ||||||||
| "Starting", | ||||||||
| format!("{} on http://{}:{}", image, ip, run_args.port), | ||||||||
| ); | ||||||||
| eprintln!(); | ||||||||
| if !run_args.quiet { | ||||||||
| eprintln!(); | ||||||||
| cargo_green_eprintln( | ||||||||
| "Starting", | ||||||||
| format!("{} on http://{}:{}", image, ip, run_args.port), | ||||||||
| ); | ||||||||
| eprintln!(); | ||||||||
| } | ||||||||
| info!(image, "Spawning 'docker run' process"); | ||||||||
| let mut docker = tokio::process::Command::new("docker"); | ||||||||
| docker | ||||||||
|
|
@@ -1551,12 +1564,14 @@ impl Shuttle { | |||||||
| .context("spawning 'docker run' process")? | ||||||||
| } else { | ||||||||
| let (service, runtime_executable) = s_re.context("developer skill issue")?; | ||||||||
| eprintln!(); | ||||||||
| cargo_green_eprintln( | ||||||||
| "Starting", | ||||||||
| format!("{} on http://{}:{}", service.target_name, ip, run_args.port), | ||||||||
| ); | ||||||||
| eprintln!(); | ||||||||
| if !run_args.quiet { | ||||||||
| eprintln!(); | ||||||||
| cargo_green_eprintln( | ||||||||
| "Starting", | ||||||||
| format!("{} on http://{}:{}", service.target_name, ip, run_args.port), | ||||||||
| ); | ||||||||
| eprintln!(); | ||||||||
| } | ||||||||
| info!( | ||||||||
| path = %runtime_executable.display(), | ||||||||
| "Spawning runtime process", | ||||||||
|
|
@@ -1723,14 +1738,17 @@ impl Shuttle { | |||||||
| &self, | ||||||||
| project_args: &ProjectArgs, | ||||||||
| build_args: &BuildArgsShared, | ||||||||
| quiet: bool, | ||||||||
| ) -> Result<()> { | ||||||||
| let project_name = project_args.local_project_name()?; | ||||||||
| let project_directory = self.ctx.project_directory(); | ||||||||
|
|
||||||||
| let metadata = cargo_metadata(project_directory)?; | ||||||||
| let rust_build_args = gather_rust_build_args(&metadata)?; | ||||||||
|
|
||||||||
| cargo_green_eprintln("Building", format!("{} with docker", project_name)); | ||||||||
| if !quiet { | ||||||||
| cargo_green_eprintln("Building", format!("{} with docker", project_name)); | ||||||||
| } | ||||||||
|
|
||||||||
| let tempdir = tempfile::Builder::new() | ||||||||
| .prefix("shuttle-build-") | ||||||||
|
|
@@ -1785,7 +1803,9 @@ impl Shuttle { | |||||||
| bail!("Docker build error"); | ||||||||
| } | ||||||||
|
|
||||||||
| cargo_green_eprintln("Finished", "building with docker"); | ||||||||
| if !quiet { | ||||||||
| cargo_green_eprintln("Finished", "building with docker"); | ||||||||
| } | ||||||||
|
|
||||||||
| Ok(()) | ||||||||
| } | ||||||||
|
|
||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Missing function documentation explaining the purpose of the new
quietparameterContext Used: Context from
dashboard- Include comments explaining the purpose of functions, especially for new or complex functionality. (source)Prompt To Fix With AI