Skip to content
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

Add spawn_restricted_if #2

Closed
funnyboy-roks opened this issue Jan 13, 2025 · 0 comments · Fixed by #4
Closed

Add spawn_restricted_if #2

funnyboy-roks opened this issue Jan 13, 2025 · 0 comments · Fixed by #4
Labels
enhancement New feature or request

Comments

@funnyboy-roks
Copy link
Member

funnyboy-roks commented Jan 13, 2025

Add a spawn_restricted_if method to the CommandExt that accepts an Option<Rules> and only spawns restricted if those rules are Some.

Command::new("foo")
    .arg("bar")
    .spawn_restricted_if(optional_rules)

spawn_restricted_if is maybe not the greatest name. We may want to come up with something better.

This would allow us to get rid of some ghastly code:

let mut cmd = Command::new("foo");
cmd.current_dir(cwd);
let output = if let Some(compile_rules) = compile_rules {
    cmd.spawn_restricted(compile_rules)
} else {
    cmd.spawn()
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant