Skip to content

Commit 683b3ee

Browse files
committed
Add a --quiet argument
1 parent 9598497 commit 683b3ee

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

src/args.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ where
4747
let mut cargo_args = Vec::new();
4848
let mut run_args = Vec::new();
4949
let mut run_args_started = false;
50+
let mut quiet = false;
5051
{
5152
fn set<T>(arg: &mut Option<T>, value: Option<T>) -> Result<(), ErrorString> {
5253
let previous = mem::replace(arg, value);
@@ -69,6 +70,9 @@ where
6970
"--version" => {
7071
return Ok(Command::Version);
7172
}
73+
"--quiet" => {
74+
quiet = true;
75+
}
7276
"--bin" => {
7377
let next = arg_iter.next();
7478
set(&mut bin_name, next.clone())?;
@@ -142,6 +146,7 @@ where
142146
target,
143147
manifest_path,
144148
release: release.unwrap_or(false),
149+
quiet,
145150
}))
146151
}
147152

@@ -151,6 +156,8 @@ pub struct Args {
151156
pub cargo_args: Vec<String>,
152157
/// All arguments that are passed to the runner.
153158
pub run_args: Vec<String>,
159+
/// Suppress any output to stdout.
160+
pub quiet: bool,
154161
/// The manifest path (also present in `cargo_args`).
155162
manifest_path: Option<PathBuf>,
156163
/// The name of the binary (passed `--bin` argument) (also present in `cargo_args`).
@@ -207,6 +214,8 @@ where
207214
A: Iterator<Item = String>,
208215
{
209216
let mut executable = None;
217+
let mut quiet = false;
218+
210219
let mut arg_iter = args.into_iter().fuse();
211220

212221
loop {
@@ -217,6 +226,9 @@ where
217226
Some("--version") => {
218227
return Ok(Command::Version);
219228
}
229+
Some("--quiet") => {
230+
quiet = true;
231+
}
220232
Some(exe) if executable.is_none() => {
221233
let path = Path::new(exe);
222234
let path_canonicalized = path.canonicalize().map_err(|err| {
@@ -235,11 +247,14 @@ where
235247

236248
Ok(Command::Runner(RunnerArgs {
237249
executable: executable.ok_or("excepted path to kernel executable as first argument")?,
250+
quiet,
238251
}))
239252
}
240253

241254
#[derive(Debug, Clone)]
242255
pub struct RunnerArgs {
243256
pub executable: PathBuf,
257+
/// Suppress any output to stdout.
258+
pub quiet: bool,
244259
}
245260

src/subcommand/build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ pub(crate) fn build(mut args: Args) -> Result<(), ErrorString> {
66
let config = config::read_config(builder.kernel_manifest_path().to_owned())?;
77
args.apply_default_target(&config, builder.kernel_root());
88

9-
build_impl(&builder, &mut args, false).map(|_| ())
9+
let quiet = args.quiet;
10+
build_impl(&builder, &mut args, quiet).map(|_| ())
1011
}
1112

1213
pub(crate) fn build_impl(

src/subcommand/run.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ pub(crate) fn run(mut args: Args) -> Result<i32, ErrorString> {
88
let config = config::read_config(builder.kernel_manifest_path().to_owned())?;
99
args.apply_default_target(&config, builder.kernel_root());
1010

11-
let bootimages = build::build_impl(&builder, &mut args, false)?;
11+
let quiet = args.quiet;
12+
let bootimages = build::build_impl(&builder, &mut args, quiet)?;
1213
let bootimage_path = bootimages.first().ok_or("no bootimages created")?;
1314
if bootimages.len() > 1 {
1415
Err("more than one bootimage created")?;

src/subcommand/runner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub(crate) fn runner(args: RunnerArgs) -> Result<i32, ErrorString> {
1919
parent.join(format!("bootimage-{}.bin", file_stem))
2020
};
2121

22-
builder.create_bootimage(&args.executable, &bootimage_bin, false)?;
22+
builder.create_bootimage(&args.executable, &bootimage_bin, args.quiet)?;
2323

2424
let mut command = process::Command::new(&config.run_command[0]);
2525
for arg in &config.run_command[1..] {

0 commit comments

Comments
 (0)