Skip to main content

haste_health/commands/
doc.rs

1use haste_fhir_operation_error::OperationOutcomeError;
2
3use crate::Cli;
4
5/// Runs the `doc` command: renders this CLI's `--help` text for every command to Markdown.
6pub(crate) async fn run(output: &str) -> Result<(), OperationOutcomeError> {
7    let markdown: String = clap_markdown::help_markdown::<Cli>();
8
9    let top_string = "
10| Context | Invocation                                                   |
11| ------- | ------------------------------------------------------------ |
12| npm     | `npm install -g haste-health`, then `haste-health <command>` |
13| npx     | `npx haste-health <command>`                                 |
14| Source  | `cargo run <command>`                                        |
15| Binary  | `./haste-health <command>`                                   |
16| Docker  | `docker run <image> <command>`                               |
17";
18
19    let markdown = format!("{top_string}\n\n{markdown}");
20
21    tokio::fs::write(output, markdown).await.map_err(|e| {
22        OperationOutcomeError::error(
23            haste_fhir_model::r4::generated::terminology::IssueType::exception(),
24            e.to_string(),
25        )
26    })?;
27
28    Ok(())
29}