-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
350a16d
commit c737b2b
Showing
5 changed files
with
46 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use std::{ | ||
process::{exit, Command, Stdio}, | ||
str::FromStr, | ||
}; | ||
|
||
use clap::Parser; | ||
use miette::IntoDiagnostic; | ||
|
||
use crate::{github::Version, utils::ensure_python, DEFAULT_PYTHON_VERSION}; | ||
|
||
/// Install and run a Python package. | ||
#[derive(Parser, Debug)] | ||
pub struct Args { | ||
/// Python version to install package with | ||
#[arg(short, long, default_value_t = Version::from_str(DEFAULT_PYTHON_VERSION).unwrap())] | ||
python: Version, | ||
|
||
/// Arguments to pass to the command invocation | ||
#[arg(num_args = 0..)] | ||
run_args: Vec<String>, | ||
} | ||
|
||
pub async fn execute(args: Args) -> miette::Result<()> { | ||
let (_, python_bin_path) = ensure_python(args.python).await?; | ||
|
||
let output = Command::new(python_bin_path) | ||
.args(args.run_args) | ||
.stdin(Stdio::inherit()) | ||
.stdout(Stdio::inherit()) | ||
.stderr(Stdio::inherit()) | ||
.output() | ||
.into_diagnostic()?; | ||
|
||
exit(output.status.code().unwrap_or(1)); | ||
} |
This file contains 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pub mod create; | ||
pub mod ensurepath; | ||
pub mod exec; | ||
pub mod install; | ||
pub mod list; | ||
pub mod run; |
This file contains 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