Add task docs and default keybindings (#8123)
Also group task source modules together Release Notes: - N/A --------- Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
This commit is contained in:
parent
b9151b9506
commit
0c939e5dfc
11 changed files with 84 additions and 64 deletions
|
@ -12,9 +12,53 @@ use schemars::{gen::SchemaSettings, JsonSchema};
|
|||
use serde::{Deserialize, Serialize};
|
||||
use util::ResultExt;
|
||||
|
||||
use crate::{Source, StaticTask, Task};
|
||||
use crate::{Source, SpawnInTerminal, Task, TaskId};
|
||||
use futures::channel::mpsc::UnboundedReceiver;
|
||||
|
||||
/// A single config file entry with the deserialized task definition.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
struct StaticTask {
|
||||
id: TaskId,
|
||||
definition: Definition,
|
||||
}
|
||||
|
||||
impl StaticTask {
|
||||
pub(super) fn new(id: usize, task_definition: Definition) -> Self {
|
||||
Self {
|
||||
id: TaskId(format!("static_{}_{}", task_definition.label, id)),
|
||||
definition: task_definition,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Task for StaticTask {
|
||||
fn exec(&self, cwd: Option<PathBuf>) -> Option<SpawnInTerminal> {
|
||||
Some(SpawnInTerminal {
|
||||
id: self.id.clone(),
|
||||
cwd,
|
||||
use_new_terminal: self.definition.use_new_terminal,
|
||||
allow_concurrent_runs: self.definition.allow_concurrent_runs,
|
||||
label: self.definition.label.clone(),
|
||||
command: self.definition.command.clone(),
|
||||
args: self.definition.args.clone(),
|
||||
env: self.definition.env.clone(),
|
||||
separate_shell: false,
|
||||
})
|
||||
}
|
||||
|
||||
fn name(&self) -> &str {
|
||||
&self.definition.label
|
||||
}
|
||||
|
||||
fn id(&self) -> &TaskId {
|
||||
&self.id
|
||||
}
|
||||
|
||||
fn cwd(&self) -> Option<&Path> {
|
||||
self.definition.cwd.as_deref()
|
||||
}
|
||||
}
|
||||
|
||||
/// The source of tasks defined in a tasks config file.
|
||||
pub struct StaticSource {
|
||||
tasks: Vec<StaticTask>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue