Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 4 additions & 2 deletions codex-plugin/plugins/spacetimedb/skills/cli/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ spacetime logs my-database -f # follow logs
spacetime logs my-database -n 100 # up to 100 log lines

# Describe schema
# (without --json, output is human-readable text)
spacetime describe my-database --json
spacetime describe my-database table users --json
spacetime describe my-database reducer my_reducer --json
spacetime describe my-database tables --json # also reducers, procedures, types
spacetime describe my-database tables users --json
spacetime describe my-database reducers my_reducer --json
```

### Database Management
Expand Down
28 changes: 28 additions & 0 deletions crates/cli/src/common_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@ pub enum ClearMode {
Never, // parses as "never"
}

#[derive(Clone, Copy, PartialEq)]
pub enum Format {
Text,
Json,
}

impl clap::ValueEnum for Format {
fn value_variants<'a>() -> &'a [Self] {
&[Self::Text, Self::Json]
}

fn to_possible_value(&self) -> Option<clap::builder::PossibleValue> {
match self {
Self::Text => Some(clap::builder::PossibleValue::new("text").aliases(["default", "txt"])),
Self::Json => Some(clap::builder::PossibleValue::new("json")),
}
}
}

pub fn server() -> Arg {
Arg::new("server")
.long("server")
Expand All @@ -30,6 +49,15 @@ pub fn yes() -> Arg {
.help("Run non-interactively wherever possible. This will answer \"yes\" to almost all prompts, but will sometimes answer \"no\" to preserve non-interactivity (e.g. when prompting whether to log in with spacetimedb.com).")
}

/// The `--format` arg, parsed as a [`Format`]. Callers supply their own `.help(...)`.
pub fn format() -> Arg {
Arg::new("format")
.long("format")
.default_value("text")
.required(false)
.value_parser(value_parser!(Format))
}

pub fn confirmed() -> Arg {
Arg::new("confirmed")
.required(false)
Expand Down
Loading
Loading