gd_cli¶
The guidedog command line as a library: it reads a command line, does what it asks, reports on standard error, and returns the exit status. cmd/guidedog is a call to run; a program with plugins linked in calls run_with with its registry.
fn main() -> std::process::ExitCode {
let linked = gd_plugins::Registry::new(Vec::new()).unwrap_or_default();
gd_cli::run_with(linked)
}
The staged path: parse_command turns words into a typed Command (plain data, checked, with Elm-style usage problems), and run_in runs one command line with the streams given, which is how tests capture what a command prints.
Exit statuses: 0 success, 1 invalid content or a failed build, 2 usage or configuration, 3 limits and memory, 4 files and programs, 5 internal, 6 and 7 for publications not confirmed or unknown, 130 cancelled.
Structs
- pub struct gd_cli::MigrateCommand¶
-
guidedog migrate [conf.py|DIR].Fields
- pub input: PathBuf¶
-
The conf.py, or the folder holding it.
- pub output: MigrateOutput¶
-
-o.
- pub force: bool¶
-
--force: replace an existing conf.toml.
- pub struct gd_cli::BuildCommand¶
-
guidedog build: what to load, what to build, and how.Fields
- pub dir: PathBuf¶
-
The project folder (the sphinx-build forms: the source folder).
- pub kind: BuilderKind¶
-
The builder.
- pub load: LoadOptions¶
-
-c,-C,-D, and the sphinx-build forms』 folders.
- pub options: BuildOptions¶
-
-a,-E,-n,-W,--keep-going,--untrusted,-j,-t, the limits, the budget, and the output folder of the sphinx-build forms.on_budgetandnoware set when the build runs.
- pub memory: MemoryMode¶
-
--memory.
- pub verbose: u32¶
-
-v, repeatable: show notes too.
- pub struct gd_cli::CleanCommand¶
-
guidedog clean [PROJECT].Fields
- pub dir: PathBuf¶
-
The project folder.
- pub struct gd_cli::ConvertCommand¶
-
guidedog convert INPUT: one file to HTML or PDF, without a project. The formats are resolved from the options and the file suffixes while parsing.Fields
- pub force: bool¶
-
--force: replace an existing output.
- pub raw: ContentPolicy¶
-
--raw: what happens to raw HTML or Typst content.
- pub strict: bool¶
-
--strict: warnings fail the conversion.
- pub fragment: bool¶
-
--fragment: the body only.
- pub number_sections: bool¶
-
--number-sections.
- pub math: MathOutput¶
-
--math: how HTML shows formulas.
- pub embed_pictures: bool¶
-
--embed-pictures: draw graphs, Typst diagrams and scores into the HTML.
- pub max_picture_kib: Option<usize>¶
-
--max-picture-kib: the size of all embedded pictures together, in KiB.
- pub keep_going: bool¶
-
--keep-going: write the output although the content has errors.
- pub font_paths: Vec<PathBuf>¶
-
--font-path, repeatable.
- pub offline: bool¶
-
--offline.
- pub embedded_fonts_only: bool¶
-
--embedded-fonts-only.
- pub struct gd_cli::CapabilitiesCommand¶
-
guidedog capabilities.Fields
- pub json: bool¶
-
--jsonor--format=jsoninstead of the summary.
- pub struct gd_cli::FormatsCommand¶
-
guidedog formats.Fields
- pub json: bool¶
-
--format=jsoninstead of the table.
- pub struct gd_cli::IntlCommand¶
-
guidedog intl update|stat [PROJECT], with sphinx-intl’s options.Fields
- pub action: IntlAction¶
-
update or stat.
- pub dir: PathBuf¶
-
The project folder.
- pub load: LoadOptions¶
-
-cand-D.
- pub line_width: usize¶
-
-w(default 76).
- pub obsolete: bool¶
-
Keep messages the templates no longer have (
--no-obsoleteclears it).
- pub struct gd_cli::ExtensionCommand¶
-
A command a plugin adds, as a command line names it.
Fields
- pub extension: crate::Extension¶
-
The command and the plugin that contributes it.
- pub help: bool¶
-
--helpor-hwas given (before--): guidedog shows the command’s help.
- pub struct gd_cli::QuickstartCommand¶
-
guidedog quickstart [DIR]: the answers given as options; a terminal asks for the rest unlessquiet.Fields
- pub dir: PathBuf¶
-
Where to create the project.
- pub quiet: bool¶
-
-q: ask nothing.
-
-a.
- pub struct gd_cli::ServeCommand¶
-
guidedog serve: the HTML build it repeats, and the listen address.Fields
- pub build: BuildCommand¶
-
The build to run first and on every change (always
html).
- pub host: std::net::IpAddr¶
-
--host(default 127.0.0.1).
- pub port: u16¶
-
--port(default 8000).
- pub struct gd_cli::Output¶
-
How the command reports, whatever it runs:
--color,--diagnostics,-q.Fields
- pub diagnostics: Diagnostics¶
-
--diagnostics.
- pub quiet: bool¶
-
-q: no success messages; warnings and errors still show.
- pub struct gd_cli::Parsed¶
-
A parsed command line: how to report, and the command, or the usage problem that stopped parsing (reported as
outputasks).Fields
- pub command: Result<Command, gd_host::Problem>¶
-
The command to run, or why the command line is not one.
- pub struct gd_cli::PluginCommand¶
-
guidedog plugin ....Fields
- pub action: PluginAction¶
-
The subcommand.
- pub yes: bool¶
-
--yes: register without asking.
- pub struct gd_cli::PublishCommand¶
-
guidedog publish --publisher=ID --config=FILE.Fields
- pub dry_run: bool¶
-
--dry-run: build and plan, publish nothing.
- pub verbose: bool¶
-
--verbose: list every change of the plan.
- pub struct gd_cli::Streams<'a>¶
-
The streams a command line runs with, borrowed for the run.
Fields
- pub input: &'a mut dyn BufRead¶
-
Answers to questions, one per line.
Trait Implementations
- impl std::fmt::Debug for Streams<'_>
-
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result
- pub struct gd_cli::Terminals¶
-
Whether each standard stream is a terminal: colors (
--color=auto) and questions (only a person at a terminal is asked) depend on it.Fields
- pub stdin: bool¶
-
Standard input is a terminal.
- pub stdout: bool¶
-
Standard output is a terminal.
- pub stderr: bool¶
-
Standard error is a terminal.
Implementations
- pub struct gd_cli::Extension¶
-
A command a plugin adds to guidedog’s command line, and the plugin that runs it.
Fields
- pub info: CommandInfo¶
-
Its name, summary, help and options, as the plugin declares them.
- pub linked: bool¶
-
The plugin is linked into this program (not a registered program).
Implementations
Enums
- pub enum gd_cli::ColorMode¶
-
When the command styles its output with colors.
Variants
- Auto¶
-
Only on a terminal, unless
NO_COLORis set orTERMisdumb.
- Always¶
-
Always.
- Never¶
-
Never.
- pub enum gd_cli::Command¶
-
What a command line asks for.
Variants
- Licenses¶
-
--licenses.
- Formats(FormatsCommand)¶
-
formats.
- Capabilities(CapabilitiesCommand)¶
-
capabilities.
- Convert(Box<ConvertCommand>)¶
-
convert.
- Quickstart(QuickstartCommand)¶
-
quickstart.
- Build(Box<BuildCommand>)¶
-
build(and the sphinx-build forms).
- Serve(Box<ServeCommand>)¶
-
serve.
- Clean(CleanCommand)¶
-
clean.
- Migrate(MigrateCommand)¶
-
migrate.
- Intl(IntlCommand)¶
-
intl updateandintl stat.
- Plugin(PluginCommand)¶
-
plugin ....
- Publish(PublishCommand)¶
-
publish --publisher=ID.
- Extension(ExtensionCommand)¶
-
A command a plugin adds, such as
pages workfloworpublish pages.
- pub enum gd_cli::Diagnostics¶
-
How problems and reports are written on standard error.
Variants
- Text¶
-
Explained, Elm-style reports.
- Json¶
-
One JSON object per report.
- pub enum gd_cli::IntlAction¶
-
The two
intlcommands.Variants
- Update¶
-
Create or merge the catalogs from the templates.
- Stat¶
-
Count what is translated.
- pub enum gd_cli::MemoryMode¶
-
What a build does when it reaches its memory budget.
Variants
- Ask¶
-
A terminal asks (raise the budget, or stop); elsewhere the build stops.
- Stop¶
-
--memory=ram: stop at the budget without asking.
- pub enum gd_cli::MigrateOutput¶
-
Where
migratewrites conf.toml.Variants
- Beside¶
-
Beside the conf.py.
- File(PathBuf)¶
-
-o FILE.
- Stdout¶
-
-o -: standard output.
- pub enum gd_cli::PluginAction¶
-
What
guidedog plugindoes.Variants
- List¶
-
list.
Functions
- pub fn gd_cli::extensions(linked: &Registry, machine: bool) -> Vec<Extension>¶
-
The commands the plugins in
linkedadd, then (whenmachine) those of the programs registered on this machine. A name already taken, by guidedog or an earlier plugin, is skipped. An unreadable machine registry adds nothing here;guidedog plugin listreports it.
- pub fn gd_cli::parse_command(args: &[String]) -> Parsed¶
-
Reads a command line (without the program name) into the command it asks for, with guidedog’s own commands only. Never fails: a mistake is returned as the command’s problem, beside the reporting options read so far, so that it is reported as
--diagnosticsasks.
- pub fn gd_cli::parse_command_with(args: &[String], extensions: &[Extension]) -> Parsed¶
-
parse_commandknowing the commands plugins add (crate::extensions): a word guidedog does not know, or apublishtarget, names one of them.
- pub fn gd_cli::full_version() -> String¶
-
What the command prints as its version:
VERSIONandVERSION_SUFFIX.
- pub fn gd_cli::version_text() -> String¶
-
The versions built into the program, one per line: Guidedog, the Guidedoc engine and its document schema, the tree-sitter grammars, and the Graphviz library. The crash report starts with it;
--versionadds the Typst backend it finds.
- pub fn gd_cli::run() -> ExitCode¶
-
Runs the process’s command line with no linked plugin (registered programs are still found) and returns its exit status.
- pub fn gd_cli::run_with(linked: Registry) -> ExitCode¶
-
Runs the process’s command line (its arguments after the program name) with the plugins in
linked, which are looked up before the machine’s registered programs. Returns the exit status.
- pub fn gd_cli::run_args(args: &[String], linked: Registry) -> ExitCode¶
-
Runs the command line
args(without the program name) withlinkedon the process’s standard streams; returns the exit status.
- pub fn gd_cli::run_status(args: &[String], linked: &Registry) -> i32¶
-
run_argsreturning the exit status as a number, for amainthat wraps it (ingd_host::catch_crash, which takes a number).
- pub fn gd_cli::run_in(args: &[String], linked: &Registry, streams: Streams<'_>) -> i32¶
-
Runs the command line
args(without the program name) withlinkedand the streams given, and returns the exit status. Commands that run other programs (plugin run) or ask questions during a build use the process’s own streams.
Constants
- pub const gd_cli::VERSION: &str = env!("CARGO_PKG_VERSION")¶
-
The Guidedog release this program belongs to: the workspace version, which the file
VERSIONat the repository root repeats for release tooling (a test checks both).