Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI - Add feature to print markdown docs #2276

Merged
merged 18 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ bytestring = { version = "1.2.0", features = ["serde"] }
cargo_metadata = "0.17.0"
chrono = { version = "0.4.24", default-features = false }
clap = { version = "4.2.4", features = ["derive", "wrap_help"] }
clap-markdown = "0.1.4"
colored = "2.0.0"
console = { version = "0.15.6" }
convert_case = "0.6.0"
Expand Down
4 changes: 4 additions & 0 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ license-file = "LICENSE"
description = "A command line interface for SpacetimeDB"
rust-version.workspace = true

[features]
markdown-docs = []

[lib]
bench = false

Expand Down Expand Up @@ -70,6 +73,7 @@ walkdir.workspace = true
wasmbin.workspace = true
wasmtime.workspace = true
webbrowser.workspace = true
clap-markdown.workspace = true

[target.'cfg(windows)'.dependencies]
windows-sys = { workspace = true, features = ["Win32_System_Console"] }
Expand Down
9 changes: 9 additions & 0 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use spacetimedb_paths::{RootDir, SpacetimePaths};
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;

#[cfg(not(feature = "markdown-docs"))]
#[tokio::main]
async fn main() -> anyhow::Result<ExitCode> {
// Compute matches before loading the config, because `Config` has an observable `drop` method
Expand All @@ -31,6 +32,14 @@ async fn main() -> anyhow::Result<ExitCode> {
exec_subcommand(config, &paths, root_dir, cmd, subcommand_args).await
}

#[cfg(feature = "markdown-docs")]
#[tokio::main]
async fn main() -> anyhow::Result<ExitCode> {
let markdown = clap_markdown::help_markdown_command(&get_command());
println!("{}", markdown);
Ok(ExitCode::SUCCESS)
}

fn get_command() -> Command {
Command::new("spacetime")
.version(version::CLI_VERSION)
Expand Down
Loading