# lukeed/sade architecture

> Architecture diagram of the GitHub repository lukeed/sade, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lukeed/sade
- Repository: https://github.com/lukeed/sade

## Overview

Sade is a small CLI framework for defining commands, options, aliases, and handlers, then parsing argv, validating arguments, and invoking the selected handler. It also generates command and program help, reports errors, and supports version output. The Node implementation and a Deno variant have separate runtime modules and utility helpers. The README documents capabilities beyond the sampled code, including single-command mode and subcommands; those links are cited to the README rather than treated as independently inspected implementation.

Main entry points: [`src/index.js`](https://github.com/lukeed/sade/blob/master/src/index.js) (Argument Parsing), [`deno/mod.js`](https://github.com/lukeed/sade/blob/master/deno/mod.js) (Deno Parsing), [`src/utils.js`](https://github.com/lukeed/sade/blob/master/src/utils.js) (Help Generation), [`deno/utils.js`](https://github.com/lukeed/sade/blob/master/deno/utils.js) (Deno Help and Errors)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["CLI Definition"]
  node_node_api["Node CLI API<br/>[index.js]"]
  node_command_config["Command Registry<br/>[index.js]"]
  node_option_config["Option Configuration<br/>[index.js]"]
  node_deno_api["Deno CLI API<br/>[mod.js]"]
end

subgraph group_runtime["Parsing and Execution"]
  node_argv_parser["Argument Parsing<br/>[index.js]"]
  node_command_select["Command Resolution<br/>[index.js]"]
  node_validation["Argument Validation<br/>[index.js]"]
  node_handler["Command Handler"]
  node_deno_runtime["Deno Parsing<br/>[mod.js]"]
end

subgraph group_output["Help and Feedback"]
  node_help_output["Help Generation<br/>[utils.js]"]
  node_formatting["Help Formatting<br/>[utils.js]"]
  node_error_output["Error Reporting<br/>[utils.js]"]
  node_version_output["Version Output<br/>[index.js]"]
  node_deno_output["Deno Help and Errors<br/>[utils.js]"]
end

node_author(("CLI App Author"))
node_cli_user(("CLI User"))
node_mri["mri Parser"]
node_deno_flags["Deno Flags Parser"]

node_author -->|"defines CLI"| node_node_api
node_node_api -->|"registers commands"| node_command_config
node_author -->|"defines options"| node_option_config
node_node_api -->|"configures flags"| node_option_config
node_author -.->|"defines CLI"| node_deno_api
node_cli_user -->|"provides argv"| node_argv_parser
node_argv_parser -->|"parses flags"| node_mri
node_argv_parser -->|"resolves command"| node_command_select
node_argv_parser -->|"checks arguments"| node_validation
node_argv_parser -->|"invokes handler"| node_handler
node_argv_parser -->|"shows help"| node_help_output
node_argv_parser -->|"reports errors"| node_error_output
node_argv_parser -->|"prints version"| node_version_output
node_deno_runtime -->|"parses flags"| node_deno_flags
node_deno_runtime -->|"uses output helpers"| node_deno_output
node_help_output -->|"formats sections"| node_formatting

click node_node_api "https://github.com/lukeed/sade/blob/master/src/index.js"
click node_command_config "https://github.com/lukeed/sade/blob/master/src/index.js"
click node_option_config "https://github.com/lukeed/sade/blob/master/src/index.js"
click node_deno_api "https://github.com/lukeed/sade/blob/master/deno/mod.js"
click node_argv_parser "https://github.com/lukeed/sade/blob/master/src/index.js"
click node_command_select "https://github.com/lukeed/sade/blob/master/src/index.js"
click node_validation "https://github.com/lukeed/sade/blob/master/src/index.js"
click node_deno_runtime "https://github.com/lukeed/sade/blob/master/deno/mod.js"
click node_help_output "https://github.com/lukeed/sade/blob/master/src/utils.js"
click node_formatting "https://github.com/lukeed/sade/blob/master/src/utils.js"
click node_error_output "https://github.com/lukeed/sade/blob/master/src/utils.js"
click node_version_output "https://github.com/lukeed/sade/blob/master/src/index.js"
click node_deno_output "https://github.com/lukeed/sade/blob/master/deno/utils.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_api,node_command_config,node_option_config,node_deno_api,node_cli_user toneBlue
class node_argv_parser,node_command_select,node_validation,node_handler,node_deno_runtime toneAmber
class node_help_output,node_formatting,node_error_output,node_version_output,node_deno_output toneMint
class node_author,node_mri,node_deno_flags toneIndigo
```

## Components

### CLI Definition

- [Node CLI API](https://github.com/lukeed/sade/blob/master/src/index.js): `src/index.js`
- [Command Registry](https://github.com/lukeed/sade/blob/master/src/index.js): `src/index.js`
- [Option Configuration](https://github.com/lukeed/sade/blob/master/src/index.js): `src/index.js`
- [Deno CLI API](https://github.com/lukeed/sade/blob/master/deno/mod.js): `deno/mod.js`

### Parsing and Execution

- [Argument Parsing](https://github.com/lukeed/sade/blob/master/src/index.js): `src/index.js`
- [Command Resolution](https://github.com/lukeed/sade/blob/master/src/index.js): `src/index.js`
- [Argument Validation](https://github.com/lukeed/sade/blob/master/src/index.js): `src/index.js`
- **Command Handler**
- [Deno Parsing](https://github.com/lukeed/sade/blob/master/deno/mod.js): `deno/mod.js`

### Help and Feedback

- [Help Generation](https://github.com/lukeed/sade/blob/master/src/utils.js): `src/utils.js`
- [Help Formatting](https://github.com/lukeed/sade/blob/master/src/utils.js): `src/utils.js`
- [Error Reporting](https://github.com/lukeed/sade/blob/master/src/utils.js): `src/utils.js`
- [Version Output](https://github.com/lukeed/sade/blob/master/src/index.js): `src/index.js`
- [Deno Help and Errors](https://github.com/lukeed/sade/blob/master/deno/utils.js): `deno/utils.js`

### Other components

- **CLI App Author**
- **CLI User**
- **mri Parser**
- **Deno Flags Parser**

## Connections

- CLI App Author → Node CLI API: defines CLI (evidence: `readme.md`)
- Node CLI API → Command Registry: registers commands (evidence: `src/index.js`)
- CLI App Author → Option Configuration: defines options (evidence: `readme.md`)
- Node CLI API → Option Configuration: configures flags (evidence: `src/index.js`)
- CLI App Author → Deno CLI API: defines CLI
- CLI User → Argument Parsing: provides argv (evidence: `readme.md`)
- Argument Parsing → mri Parser: parses flags (evidence: `src/index.js`)
- Argument Parsing → Command Resolution: resolves command (evidence: `src/index.js`)
- Argument Parsing → Argument Validation: checks arguments (evidence: `src/index.js`)
- Argument Parsing → Command Handler: invokes handler (evidence: `src/index.js`)
- Argument Parsing → Help Generation: shows help (evidence: `src/index.js`)
- Argument Parsing → Error Reporting: reports errors (evidence: `src/index.js`)
- Argument Parsing → Version Output: prints version (evidence: `src/index.js`)
- Deno Parsing → Deno Flags Parser: parses flags (evidence: `deno/mod.js`)
- Deno Parsing → Deno Help and Errors: uses output helpers (evidence: `deno/mod.js`)
- Help Generation → Help Formatting: formats sections (evidence: `src/utils.js`)
