Skip to content
Merged
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
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ Use the commands directly in your terminal for validation and analysis:
# Validate the graph
docgraph check .

# Trace relationships
docgraph trace UC_LOGIN FR_EMAIL_LOGIN
# Trace relationships (using query)
docgraph query "MATCH p=(src)-[*]->(dst) WHERE src.id = 'UC_LOGIN' AND dst.id = 'FR_EMAIL_LOGIN' RETURN p"
```

#### Development Setup
Expand All @@ -165,8 +165,6 @@ This will automatically run `cargo fmt`, `clippy`, `prettier`, `test`, and `docg

- `check [path]`: Validate the graph for broken links and rule violations.
- `fmt [path]`: Automatically fix fixable formatting and lint issues.
- `list <query>`: Search for nodes matching a pattern.
- `trace <from> <to>`: Trace and visualize relationship paths.
- `query <cypher>`: Execute advanced pattern matching queries.
- `describe <id>`: Show bidirectional relationships for a specific node.
- `lsp`: Start the Language Server for IDE support.
Expand All @@ -177,6 +175,12 @@ This will automatically run `cargo fmt`, `clippy`, `prettier`, `test`, and `docg

### Examples

**List nodes matching a pattern (replacement for `list` command):**

```bash
docgraph query "MATCH (n) WHERE n.id =~ 'FR-*' RETURN n.id, n.name"
```

**Find all Use Cases with "Login" in the name:**

```bash
Expand Down
34 changes: 11 additions & 23 deletions doc/requirements/functional/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,23 @@ The `graph` command shall output the graph structure in JSON format.

## List Command

The `list` command shall output nodes matching a specific query with their names.

The query can contain wildcards (`*` and `?`). If no wildcards are present, the command performs a prefix match (forward
match).
The `list` capability shall output nodes matching a specific query with their names. This is achieved using the `query`
command.

**Usage:**

```bash
docgraph list "FR-*"
docgraph list FR
docgraph query "MATCH (n) WHERE n.id =~ 'FR-*' RETURN n.id, n.name"
```

**Output format:**

```text
ID : Description
┌────────┬─────────────┐
│ n.id ┆ n.name │
╞════════╪═════════════╡
│ FR-001 ┆ ... │
└────────┴─────────────┘
```

### Realized by
Expand All @@ -52,28 +53,15 @@ ID : Description

## Trace Command

The `trace` command shall find and display all paths between a start ID and target IDs matching a query.
The `trace` capability shall find and display all paths between a start ID and target IDs matching a query. This is
achieved using the `query` command with path finding.

**Usage:**

```bash
docgraph trace <from> <to> [--direction <down|up>]
```

- `<from>`: The starting Node ID.
- `<to>`: Target ID or prefix (supports wildcards).
- `--direction`:
- `down` (default): Follow outgoing links (references).
- `up`: Follow incoming links (reverse references).

**Output format:**

```text
ID1 -> ID2 -> ID3
docgraph query "MATCH p=(src)-[*]->(dst) WHERE src.id = 'A' AND dst.id = 'B' RETURN p"
```

(Using `<-` for `up` direction)

### Realized by

- [MOD_CLI (CLI Application)](../../architecture/view/module.md#MOD_CLI)
Expand Down
3 changes: 2 additions & 1 deletion doc/usecases/cli-analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ The developer runs the `docgraph` CLI to analyze the documentation graph.
- [FR_CORE_AUDIT (Audit Logging)](../requirements/functional/core.md#FR_CORE_AUDIT) Tracking CLI usage for compliance
monitoring
- [FR_CLI_TRACE (Trace Command)](../requirements/functional/cli.md#FR_CLI_TRACE) Analyzing dependency paths between
nodes
nodes (using `query`)
- [FR_CLI_QUERY (Query Command)](../requirements/functional/cli.md#FR_CLI_QUERY) Advanced pattern matching and graph
analysis
- [FR_CLI_DESCRIBE (Describe Command)](../requirements/functional/cli.md#FR_CLI_DESCRIBE) Showing detailed metadata for
a specific node
- [FR_CLI_TYPE (Type Command)](../requirements/functional/cli.md#FR_CLI_TYPE) Filtering nodes by their defined types
- [FR_CLI_LIST (List Command)](../requirements/functional/cli.md#FR_CLI_LIST) Listing all nodes found in the workspace
(using `query`)
- [FR_CLI_VERSION (Version Command)](../requirements/functional/cli.md#FR_CLI_VERSION) Displaying the current version of
the tool
- [FR_CLI_HELP (Help Command)](../requirements/functional/cli.md#FR_CLI_HELP) Providing usage guidance for CLI commands
Expand Down
80 changes: 0 additions & 80 deletions src/cli/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,38 +51,6 @@ pub enum Commands {
#[arg(default_value = ".")]
path: PathBuf,
},
/// List spec blocks matching a query
List {
/// Query pattern (e.g., "FR-01", "FR-*"). If omitted, all blocks are listed.
///
/// Examples:
///
/// - docgraph list "FR-*"
///
/// - docgraph list
#[arg(index = 1)]
query: Option<String>,

/// Path to search for markdown files (defaults to current directory)
#[arg(long, short, default_value = ".")]
path: PathBuf,
},
/// Trace relationships between spec blocks
Trace {
/// Start ID
from: String,

/// Target ID or prefix
to: String,

/// Path to search for markdown files (defaults to current directory)
#[arg(default_value = ".")]
path: PathBuf,

/// Direction of trace (down: outgoing, up: incoming)
#[arg(long, default_value = "down")]
direction: String,
},
/// Describe a spec block and its relationships
Describe {
/// The ID of the spec block to describe
Expand Down Expand Up @@ -170,52 +138,4 @@ mod tests {
_ => panic!("Expected Check command"),
}
}

#[test]
fn test_list_query() {
let cli = Cli::parse_from(["docgraph", "list", "FR-*"]);
match cli.command {
Commands::List { query, path } => {
assert_eq!(query, Some("FR-*".to_string()));
assert_eq!(path, PathBuf::from("."));
}
_ => panic!("Expected List command"),
}
}

#[test]
fn test_list_no_query() {
let cli = Cli::parse_from(["docgraph", "list"]);
match cli.command {
Commands::List { query, path } => {
assert!(query.is_none());
assert_eq!(path, PathBuf::from("."));
}
_ => panic!("Expected List command"),
}
}

#[test]
fn test_list_with_path() {
let cli = Cli::parse_from(["docgraph", "list", "--path", "./doc"]);
match cli.command {
Commands::List { query, path } => {
assert!(query.is_none());
assert_eq!(path, PathBuf::from("./doc"));
}
_ => panic!("Expected List command"),
}
}

#[test]
fn test_list_query_with_path() {
let cli = Cli::parse_from(["docgraph", "list", "FR-*", "-p", "./doc"]);
match cli.command {
Commands::List { query, path } => {
assert_eq!(query, Some("FR-*".to_string()));
assert_eq!(path, PathBuf::from("./doc"));
}
_ => panic!("Expected List command"),
}
}
}
42 changes: 0 additions & 42 deletions src/cli/handlers/list.rs

This file was deleted.

2 changes: 0 additions & 2 deletions src/cli/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ pub mod check;
pub mod common;
pub mod describe;
pub mod graph;
pub mod list;
pub mod query;
pub mod rule;
pub mod trace;
pub mod type_cmd;
102 changes: 0 additions & 102 deletions src/cli/handlers/trace.rs

This file was deleted.

7 changes: 0 additions & 7 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ pub fn run() -> ExitCode {
Commands::Fmt { path, rule } => handlers::check::handle_fmt(path, rule),
Commands::Rule { rule } => handlers::rule::handle_rule(rule),
Commands::Graph { path } => handlers::graph::handle_graph(path),
Commands::List { query, path } => handlers::list::handle_list(query, path),
Commands::Trace {
from,
to,
path,
direction,
} => handlers::trace::handle_trace(from, to, path, direction),
Commands::Describe { id, path } => handlers::describe::handle_describe(id, path),
Commands::Type { type_id } => handlers::type_cmd::handle_type(type_id),
Commands::Query {
Expand Down
4 changes: 0 additions & 4 deletions tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ mod common;
mod describe;
#[path = "cli/graph.rs"]
mod graph;
#[path = "cli/list.rs"]
mod list;
#[path = "cli/query.rs"]
mod query;
#[path = "cli/rule.rs"]
mod rule;
#[path = "cli/trace.rs"]
mod trace;
Loading