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

feat: task confirmation #4328

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions schema/mise-task.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
}
]
},
"confirm": {
"description": "confirmation message before running this task",
"type": "string"
},
"depends": {
"oneOf": [
{
Expand Down
4 changes: 4 additions & 0 deletions schema/mise.json
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,10 @@
}
]
},
"confirm": {
"description": "confirmation message before running this task",
"type": "string"
},
"depends": {
"oneOf": [
{
Expand Down
5 changes: 5 additions & 0 deletions src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,11 @@ impl Run {
}
return Ok(());
}
if let Some(message) = &task.confirm {
if !ui::confirm(message).unwrap_or(true) {
return Err(eyre!("task cancelled"));
}
}

let config = Config::get();
let mut tools = self.tool.clone();
Expand Down
3 changes: 3 additions & 0 deletions src/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ pub struct Task {
pub cf: Option<Arc<dyn ConfigFile>>,
#[serde(skip)]
pub config_root: Option<PathBuf>,
#[serde(default)]
pub confirm: Option<String>,
#[serde(default, deserialize_with = "deserialize_arr")]
pub depends: Vec<TaskDep>,
#[serde(default, deserialize_with = "deserialize_arr")]
Expand Down Expand Up @@ -572,6 +574,7 @@ impl Default for Task {
config_source: PathBuf::new(),
cf: None,
config_root: None,
confirm: None,
depends: vec![],
depends_post: vec![],
wait_for: vec![],
Expand Down