Skip to content

Commit 532a234

Browse files
committed
docs
1 parent 5d138dc commit 532a234

9 files changed

Lines changed: 60 additions & 6 deletions

File tree

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ arrow-array = "58.3.0"
3131
arrow-schema = "58.3.0"
3232
async-channel = "2.2"
3333
async-trait = "^0.1"
34+
axum = "0.8"
3435
mockall = "0.14.0"
3536
bytes = "1.11.1"
3637
bytesize = "2"
@@ -48,6 +49,7 @@ futures = { version = "0.3", default-features = false, features = ["alloc"] }
4849
futures-core = "0.3"
4950
hyper = { version = "1.8", features = ["server", "http1"] }
5051
hyper-util = { version = "0.1.20", features = ["service", "server", "tokio"] }
52+
include_dir = "0.7"
5153
indicatif = "0.18"
5254
indoc = "2.0"
5355
parquet = "58.3.0"
@@ -73,6 +75,7 @@ toml = "0.9"
7375
tonic = { version = "^0.14", features = ["gzip"] }
7476
tonic-prost = "^0.14"
7577
tower = "^0.5"
78+
tower-serve-static = "0.1"
7679
tracing = "0.1"
7780
tracing-appender = "0.2"
7881
tracing-subscriber = { version = "0.3", features = ["fmt", "env-filter"] }

rust/crates/sift_cli/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ tokio = { workspace = true, features = ["full", "net", "time"] }
3939
tokio-stream = { workspace = true }
4040
toml = { workspace = true }
4141
zip = { workspace = true }
42+
axum.workspace = true
43+
tower-serve-static.workspace = true
44+
include_dir.workspace = true
4245

4346
[dev-dependencies]
4447
indoc = { workspace = true }

rust/crates/sift_cli/assets/docs/src/agents/mcp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The server reads credentials from your configured profile, so make sure
1414
`sift-cli ping` succeeds first. Pass `--profile` and `--disable-tls` as needed:
1515

1616
```sh
17-
sift-cli --profile staging mcp
17+
sift-cli --profile mission mcp
1818
```
1919

2020
The server communicates over stdio and is meant to be launched by an MCP client,

rust/crates/sift_cli/assets/docs/src/getting-started/profiles.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Pass `--profile <name>` to `config update`. The profile is created as its own
2121
TOML table:
2222

2323
```sh
24-
sift-cli config update --profile staging \
24+
sift-cli config update --profile mission \
2525
--grpc-uri https://api.staging.example.com \
2626
--rest-uri https://api.staging.example.com \
2727
--api-key "$SIFT_STAGING_API_KEY"
@@ -52,8 +52,8 @@ sift-cli config update --interactive
5252
`--profile` is a global flag, so it goes on any command that talks to Sift:
5353

5454
```sh
55-
sift-cli --profile staging ping
56-
sift-cli --profile staging import csv ./telemetry.csv --asset rover-1
55+
sift-cli --profile mission ping
56+
sift-cli --profile mission import csv ./telemetry.csv --asset rover-1
5757
```
5858

5959
Omit `--profile` to use the default profile.

rust/crates/sift_cli/assets/docs/src/getting-started/verifying.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ means your `grpc_uri` and `apikey` are correct and the network path is open.
1313
To verify a specific profile:
1414

1515
```sh
16-
sift-cli --profile staging ping
16+
sift-cli --profile mission ping
1717
```
1818

1919
For a non-TLS environment:

rust/crates/sift_cli/src/cli/mod.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use parquet::ComplexTypesMode;
44
pub mod hdf5;
55
pub mod tdms;
66
use hdf5::Hdf5Schema;
7-
use std::path::PathBuf;
7+
use std::{net::SocketAddr, path::PathBuf};
88
use tdms::TdmsFallbackMethod;
99

1010
pub mod channel;
@@ -41,6 +41,8 @@ pub enum Cmd {
4141
#[command(subcommand)]
4242
Config(ConfigCmd),
4343

44+
Doc(DocArgs),
45+
4446
#[command(subcommand)]
4547
Install(InstallCmd),
4648

@@ -59,6 +61,14 @@ pub enum Cmd {
5961
Ping,
6062
}
6163

64+
/// Serve the bundled Sift CLI user documentation over HTTP.
65+
#[derive(clap::Args)]
66+
pub struct DocArgs {
67+
/// Address the documentation HTTP server binds to.
68+
#[arg(long, default_value_t = Self::default_addr())]
69+
pub addr: SocketAddr,
70+
}
71+
6272
/// Install optional Sift tooling such as autocompletions or Agent skills
6373
#[derive(Subcommand)]
6474
pub enum InstallCmd {
@@ -500,3 +510,9 @@ pub struct ImportHdf5Args {
500510
#[arg(long, help_heading = "One-d schema options")]
501511
pub time_name: Option<String>,
502512
}
513+
514+
impl DocArgs {
515+
fn default_addr() -> SocketAddr {
516+
"0.0.0.0:3000".parse().unwrap()
517+
}
518+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use anyhow::{Context, Result};
2+
use axum::Router;
3+
use include_dir::{Dir, include_dir};
4+
use std::process::ExitCode;
5+
use tokio::net::TcpListener;
6+
use tower_serve_static::ServeDir;
7+
8+
use crate::cli::DocArgs;
9+
10+
static STATIC_ASSETS: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/assets/docs/book");
11+
12+
pub async fn serve(args: DocArgs) -> Result<ExitCode> {
13+
let DocArgs { addr } = args;
14+
15+
let docs = ServeDir::new(&STATIC_ASSETS);
16+
17+
let router = Router::new().fallback_service(docs);
18+
19+
let ln = TcpListener::bind(addr)
20+
.await
21+
.context("failed to bind socket address")?;
22+
23+
println!("documentation available at tcp://{addr}");
24+
25+
axum::serve(ln, router)
26+
.await
27+
.context("server exited due to error")?;
28+
29+
Ok(ExitCode::SUCCESS)
30+
}

rust/crates/sift_cli/src/cmd/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::{fs::read_to_string, io::ErrorKind};
55
use toml::{Table, Value};
66

77
pub mod config;
8+
pub mod doc;
89
pub mod export;
910
pub mod import;
1011
pub mod install;

rust/crates/sift_cli/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ fn run(clargs: cli::Args) -> Result<ExitCode> {
6363
ConfigCmd::Where => return cmd::config::config_where(),
6464
ConfigCmd::Update(args) => return cmd::config::update(clargs.profile, args),
6565
},
66+
Cmd::Doc(args) => return run_future(cmd::doc::serve(args)),
6667
Cmd::Install(cmd) => match cmd {
6768
InstallCmd::Completions(cmd) => match cmd {
6869
cli::CompletionsCmd::Print(args) => return cmd::install::completions::print(args),

0 commit comments

Comments
 (0)