Add languages and reload-languages ctl verbs
Expose the language registry via ctl: `languages` lists supported src block languages (one per line), `reload-languages` reloads plugin configs from /etc/orkmode/languages and ~/.config/orkmode/languages and reports how many were loaded.
This commit is contained in:
parent
84101145d7
commit
a13f76cd40
|
|
@ -223,6 +223,8 @@ impl OrkState {
|
||||||
("archive", "archive <doc> <id> — move subtree to <doc>.org_archive", OrkState::ctl_archive),
|
("archive", "archive <doc> <id> — move subtree to <doc>.org_archive", OrkState::ctl_archive),
|
||||||
("lint", "lint [doc] — validate documents", OrkState::ctl_lint),
|
("lint", "lint [doc] — validate documents", OrkState::ctl_lint),
|
||||||
("execute", "execute <doc> [scope] [block] — run src blocks", OrkState::ctl_execute),
|
("execute", "execute <doc> [scope] [block] — run src blocks", OrkState::ctl_execute),
|
||||||
|
("languages", "languages — list supported src block languages", OrkState::ctl_languages),
|
||||||
|
("reload-languages", "reload-languages — reload language plugins from config dirs", OrkState::ctl_reload_languages),
|
||||||
];
|
];
|
||||||
|
|
||||||
let cmd = cmd.trim();
|
let cmd = cmd.trim();
|
||||||
|
|
@ -310,6 +312,21 @@ impl OrkState {
|
||||||
Ok(self.lint(target))
|
Ok(self.lint(target))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// List supported src block languages, one per line.
|
||||||
|
fn ctl_languages(&self, _args: &[&str]) -> Result<String> {
|
||||||
|
let mut out = self.list_languages().join("\n");
|
||||||
|
if !out.is_empty() {
|
||||||
|
out.push('\n');
|
||||||
|
}
|
||||||
|
Ok(out)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Reload language plugins from config dirs; report how many were loaded.
|
||||||
|
fn ctl_reload_languages(&self, _args: &[&str]) -> Result<String> {
|
||||||
|
let loaded = self.reload_languages()?;
|
||||||
|
Ok(format!("reloaded {} language config(s)\n", loaded))
|
||||||
|
}
|
||||||
|
|
||||||
/// Execute src blocks.
|
/// Execute src blocks.
|
||||||
///
|
///
|
||||||
/// Syntax: execute <doc> [<scope>] [<block>]
|
/// Syntax: execute <doc> [<scope>] [<block>]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue