cli

package
v0.420.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 33 Imported by: 0

README

CLI Module

CLI adapter layer for the DeltaScope application.

Files

File Responsibility
cli.go Bridges process execution into the testable CLI executor
root.go Builds the Cobra root command, shared CLI option state, and stable error/exit-code mapping
audit.go Implements the audit subcommand, SQL input loading, interactive stdin hinting, MySQL-style connection flag parsing, password/password-env/password-file resolution, metadata-connect-timeout parsing, password prompting, quiet/normal/github-summary rendering, and fail-threshold logic
audit_metadata.go Bridges CLI metadata-aware options (including connect timeout) into the shared metadata-preparation flow and MySQL-compatible client opener
query_access.go Implements the query-access analyze subcommand with SQL input loading, mode/dialect/schema flags, JSON output, and admission-based exit codes
query_access_test.go Verifies query-access command JSON output, exit codes, field names, mode handling, and no-audit-field-leakage
query_access_probe_boundary_no_leak_test.go No-leak regression for the MySQL/TiDB builtin-identity probe boundary on the CLI surface: asserts injected markers, identity facts, candidates, session/context, manifest, raw SQL, and severity are absent from stdout/stderr/JSON
rules.go Implements rules list (with dialect/level/kind/category/search/format/limit filters) and rules explain <rule-id> on top of the shipped rule catalog, including text and JSON output
config.go Implements the config command group, including lint (semantic validation plus rule-level replacement-hazard warnings and --strict), show-default, and wiring for status
config_init.go Implements config init and emits a deterministic default YAML template
config_status.go Implements config status <rule-id>, showing the effective ON/OFF state, level, default/current snapshots, and config effect for one rule via the config status application service, with text and JSON output
capabilities.go Implements the capabilities summary command and shared rendering helpers for human/agent discovery of shipped dialects, modes, inputs, outputs, and public surfaces (cli, http, mcp, go-api)
ddl_coverage.go Implements the ddl-coverage command for querying the generated DDL coverage catalog with text and JSON output, flag validation, and filter rendering
capability_surface.go Defines the pure-Go build capability surface and root CLI wording
capability_surface_pg.go Defines the PostgreSQL-tagged build capability surface and root CLI wording
version.go Implements the version subcommand with ASCII logo plus build-version and supported-dialect output
cli_test.go Verifies input modes, connection/password UX, exit-code behavior, capability/version wording surfaces, audit context output, explanation rendering in Markdown/JSON results, the user-facing Action Summary markdown contract (section presence, rule explain command, statement index, clean-result omission, JSON/quiet non-regression, and no severity field), github-summary format coverage (REJECT/PASS verdict, action summary, clean-result omission, no raw SQL, no severity, help advertising, unsupported-format messaging), and help advertising of all output formats
ddl_coverage_test.go Verifies ddl-coverage command filtering, text/JSON output, empty results, invalid flags, and no-leak sanity across all 400 catalog entries
rules_catalog_test.go Verifies rules list filtering (dialect, level, kind, category, search, limit), rules explain detail output, text/JSON formats, invalid flags, empty results, and no-severity sanity
audit_metadata_test.go Verifies metadata-aware CLI wiring for dialect detection, schema inference, create-table partial behavior, and metadata-connect-timeout flag validation
config_status_test.go Verifies config status text/JSON output, partial-replacement danger wording, disabled-rule wording, and error mapping (missing rule id, unknown rule, invalid format, invalid config) with no severity field
config_lint_test.go Verifies config lint warnings (level-only replacement hazard), Config OK / Config OK with warnings output and exit-code matrix, --strict, error precedence, deterministic warning ordering, and existing invalid-value errors with no severity field

Exports

  • Run()
  • Execute(ctx, args, stdin, stdout, stderr) int

Dependencies

  • Upstream: cmd/deltascope
  • Downstream: bufio, database/sql, encoding/json, internal/application/audit, internal/application/auditmeta, internal/application/configlint, internal/application/configstatus, internal/domain/policy, internal/domain/report, internal/domain/rule/catalog, internal/domain/spec, internal/infrastructure/config/viper, internal/infrastructure/metadata/mysql, internal/infrastructure/output/githubsummary, internal/infrastructure/output/json, internal/infrastructure/output/markdown, internal/interfaces/metadata, pkg/deltascope, github.com/spf13/cobra, golang.org/x/term

Notes

  • deltascope --version prints the build version plus compiled dialect surface.
  • deltascope version prints the ASCII logo plus the build version and compiled dialect surface.

Update Rule

  • If members/interfaces/dependencies change, update this file in same change.

Documentation

Overview

Package cli exposes the command-line adapter for DeltaScope. input: audit command flags, SQL text from flags/files/stdin, password source/prompt dependencies, and application audit services output: rendered audit results, connection-option validation, password resolution, and exit-code mapping for CLI audit invocations pos: CLI audit command implementation above the application service and output renderers note: if this file changes, update this header and module README.md.

Package cli exposes the command-line adapter for DeltaScope. input: metadata-aware audit connection options, SQL text, and metadata provider clients output: resolved dialect/schema context and provider wiring for metadata-aware CLI audits pos: CLI metadata-aware audit preparation between command flags and application requests note: if this file changes, update this header and module README.md.

Package cli exposes the command-line adapter for DeltaScope. input: capability command invocations plus shipped product-surface metadata output: stable human-readable summaries of supported dialects, modes, inputs, outputs, and shipped surfaces across CLI, HTTP, MCP, and Go API entrypoints pos: CLI capability discovery command above the current shipped product surface note: if this file changes, update this header and module README.md.

Package cli exposes the command-line adapter for DeltaScope. input: process control from cmd/deltascope and Cobra command execution requests output: executable CLI behavior and stable process exit codes for local audits pos: interface adapter between process entrypoint and application services note: if this file changes, update this header and module README.md.

Package cli exposes the command-line adapter for DeltaScope. input: config command invocations and YAML config files output: config lint results with validation errors and replacement warnings, default-config rendering, and rule config status wiring pos: CLI config command group for policy inspection and validation note: if this file changes, update this header and module README.md.

Package cli exposes the command-line adapter for DeltaScope. input: config init command invocations and the built-in default policy model output: a usable YAML policy template for local users and automation pos: CLI config generation command for bootstrapping DeltaScope policy files note: if this file changes, update this header and module README.md.

Package cli exposes the command-line adapter for DeltaScope. input: a rule ID, the global --config policy path, and the config status application service output: human and JSON status for one shipped rule under the default policy plus optional config pos: CLI config status command above the application config status use case note: if this file changes, update this header and module README.md.

Package cli exposes the command-line adapter for DeltaScope. input: ddl-coverage command flags and the checked-in DDL coverage catalog JSON output: filtered catalog entries rendered as human-readable text or machine-readable JSON pos: CLI ddl-coverage command for querying the generated DDL coverage catalog note: if this file changes, update this header and module README.md.

Package cli exposes the command-line adapter for DeltaScope. input: query-access command flags including connection flags, SQL text from flags/files/stdin, and the public query access API output: rendered query access results in JSON format, exit-code mapping for CI integration pos: CLI query-access command implementation above the public DeltaScope query access API note: if this file changes, update this header and module README.md.

Package cli exposes the command-line adapter for DeltaScope. input: Cobra command construction inputs, process-like stdin/stdout/stderr dependencies, and shared CLI option state output: root command wiring for audit, rules, config, capabilities, ddl-coverage, and version subcommands pos: CLI command assembly and shared option definitions note: if this file changes, update this header and module README.md.

Package cli exposes the command-line adapter for DeltaScope. input: rule catalog queries, CLI filters, and stdout/stderr command surfaces output: shipped-rule list, detail, and search rendering for CLI discovery workflows pos: CLI rule catalog command group above the explanation-oriented domain catalog note: if this file changes, update this header and module README.md.

Package cli exposes the command-line adapter for DeltaScope. input: version command invocations and the build-time version variable output: a stable printable version string for users and scripts pos: CLI metadata command implementation note: if this file changes, update this header and module README.md.

Index

Constants

This section is empty.

Variables

Version is the build version printed by the version command.

Functions

func Execute

func Execute(ctx context.Context, args []string, stdin io.Reader, stdout io.Writer, stderr io.Writer) int

Execute runs the CLI using the supplied process-like dependencies.

func Run

func Run()

Run executes the CLI against the current process environment and exits.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL