mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-03-20 09:01:05 +08:00
# Description of Changes This changes the ci runs to execute `cargo ci` instead of running commands directly from the github workflow. The goal here is to unify the commands under `cargo ci` so that it's easier and more intuitive to run locally # API and ABI breaking changes There are no API/ABI changes. <!-- If this is an API or ABI breaking change, please apply the corresponding GitHub label. --> # Expected complexity level and risk Complexity: 1 It is not a complex change as it is mostly localized to the ci runs and is easily reversible if something goes wrong. The biggest risk here is to have future CI runs break, which can be remediated by reverting these changes. <!-- How complicated do you think these changes are? Grade on a scale from 1 to 5, where 1 is a trivial change, and 5 is a deep-reaching and complex change. This complexity rating applies not only to the complexity apparent in the diff, but also to its interactions with existing and future code. If you answered more than a 2, explain what is complex about the PR, and what other components it interacts with in potentially concerning ways. --> # Testing <!-- Describe any testing you've done, and any testing you'd like your reviewers to do, so that you're confident that all the changes work as expected! --> - [x] run `cargo ci` and its subcommands locally - [x] run the github workflow against this branch to check if the CI jobs are working properly. --------- Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com> Signed-off-by: Roberto Pommella Alegro <robertoaall@gmail.com> Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com> Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
70 lines
1.7 KiB
Rust
70 lines
1.7 KiB
Rust
use clap::{Command, CommandFactory};
|
|
|
|
use crate::Cli;
|
|
|
|
// TODO: use clap_markdown instead of this custom implementation in the future
|
|
pub fn generate_cli_docs() -> String {
|
|
let mut cli = Cli::command();
|
|
let usage = generate_markdown(&mut cli, 2);
|
|
|
|
format!(
|
|
"\
|
|
# SpacetimeDB's cargo ci
|
|
|
|
## Overview
|
|
|
|
This document provides an overview of the `cargo ci` command-line tool, and documentation for each of its subcommands and options.
|
|
|
|
{}
|
|
---
|
|
|
|
This document is auto-generated by running:
|
|
|
|
```bash
|
|
cargo ci self-docs
|
|
```",
|
|
usage
|
|
)
|
|
}
|
|
|
|
fn generate_markdown(cmd: &mut Command, heading_level: usize) -> String {
|
|
let mut out = String::new();
|
|
|
|
let heading = "#".repeat(heading_level);
|
|
out.push_str(&format!("{} `{}`\n\n", heading, cmd.get_name()));
|
|
|
|
if let Some(long_about) = cmd.get_long_about() {
|
|
out.push_str(&format!("{}\n\n", long_about));
|
|
}
|
|
|
|
out.push_str(&format!("**Usage:**\n```bash\n{}\n```\n\n", cmd.render_usage()));
|
|
|
|
let mut options = String::new();
|
|
for arg in cmd.get_arguments() {
|
|
let names = arg
|
|
.get_long()
|
|
.map(|l| format!("--{}", l))
|
|
.or_else(|| arg.get_short().map(|s| format!("-{}", s)))
|
|
.unwrap_or_else(|| arg.get_id().to_string());
|
|
let help = arg.get_long_help().unwrap_or_default();
|
|
options.push_str(&format!(
|
|
"- `{}`: {}\n{}",
|
|
names,
|
|
help,
|
|
if help.to_string().lines().count() > 1 { "\n" } else { "" }
|
|
));
|
|
}
|
|
|
|
if !options.is_empty() {
|
|
out.push_str("**Options:**\n\n");
|
|
out.push_str(&options);
|
|
out.push('\n');
|
|
}
|
|
|
|
for sub in cmd.get_subcommands_mut() {
|
|
out.push_str(&generate_markdown(sub, heading_level + 1));
|
|
}
|
|
|
|
out
|
|
}
|