Skip to content

Commit

Permalink
Unify the message formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
  • Loading branch information
kakkoyun committed Sep 27, 2024
1 parent ce3c4a1 commit 30885bc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 6 additions & 9 deletions crates/uv/src/commands/project/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,13 +734,13 @@ pub(crate) async fn run(
.ok()
.into_iter()
.flatten()
.filter_map(|entry| match entry {
Ok(entry) => Some(Ok(entry)),
.map(|entry| match entry {
Ok(entry) => Ok(entry),
Err(err) => {
// If we can't read the entry, fail.
// This could be a symptom of a more serious problem.
warn!("Failed to read entry: {}", err);
Some(Err(err))
Err(err)
}
})
.collect::<Result<Vec<_>, _>>()?
Expand Down Expand Up @@ -773,16 +773,13 @@ pub(crate) async fn run(
.collect_vec();

if !commands.is_empty() {
writeln!(printer.stdout(), "The following commands are available:")?;
writeln!(printer.stdout(), "The following commands are available:\n")?;
for command in commands {
writeln!(printer.stdout(), "- {command}")?;
}
}
writeln!(
printer.stdout(),
"\nSee `uv run --help` for more information."
)?;

let help = format!("See `{}` for more information.", "uv run --help".bold());
writeln!(printer.stdout(), "\n{help}")?;
return Ok(ExitStatus::Error);
};

Expand Down
2 changes: 2 additions & 0 deletions crates/uv/tests/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ fn run_no_args() -> Result<()> {
Provide a command or script to invoke with `uv run <command>` or `uv run <script>.py`.
The following commands are available:
- python
- python3
- python3.12
Expand All @@ -247,6 +248,7 @@ fn run_no_args() -> Result<()> {
Provide a command or script to invoke with `uv run <command>` or `uv run <script>.py`.
The following commands are available:
- pydoc
- python
- pythonw
Expand Down

0 comments on commit 30885bc

Please sign in to comment.