Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::ptr;
use duckdb::{ffi, AccessMode, Config, Connection};
use serde_json::json;

pub(crate) const HELP: &str = "DuckLocal — local data workspace and headless SQL\n\nUsage:\n ducklocal [PATH ...] Open the GUI (files, folders, globs)\n ducklocal query --sql SQL [OPTIONS] Execute one statement, return JSON\n ducklocal query --sql-file FILE [OPTIONS]\n ducklocal profile TARGET [--database PATH] Per-column statistics, JSON\n ducklocal export --html [OPTIONS] APP App data as a standalone HTML file\n ducklocal check FILE [--database PATH] Validate a .dash dashboard spec\n ducklocal lsp [--database PATH] Language server for .dash files (stdio)\n ducklocal --help\n ducklocal --version\n\nQuery options:\n --sql SQL SQL text; exactly one of --sql and --sql-file is required\n --sql-file FILE UTF-8 SQL file; - reads stdin\n --database PATH File database; must exist, opened read-only by default\n --read-write Allow database writes/creation (requires --database)\n --limit N Maximum returned rows, default 1000; positive integer\n --format FORMAT json (default) or md, a Markdown table to read and quote\n --help Show this help\n\nOutput: one JSON object with columns, rows, row_count, truncated, elapsed_ms.\nColumn types are Arrow debug names, not SQL type names. A 2,000,000-cell\nbudget also applies. Limits constrain output, not computation. --format md\nrenders the same values as readable text: dates and timestamps in ISO form,\nDECIMALs with their digits, NULL as NULL. It is a rendering, not the contract;\nuse JSON where a caller parses the result.\nErrors: JSON on stderr, empty stdout; exit 2 for arguments, 1 for SQL/I/O.\nRead-only is NOT a filesystem/network sandbox: COPY can write files.\nExtensions are not automatically installed. GUI state/history is not used.\nA GUI path named `query`, `profile`, `export`, `check`, `dash` or `lsp` must be written ./query, ./profile, ./export, ./check, ./dash, ./lsp.\n\nProfile: TARGET is a data file (csv/tsv/parquet/json) or a workbook\n(xlsx/xls/xlsb/ods; its first sheet is imported and profiled), or, with\n--database, a table or view name. Per column it reports type, nulls, distinct,\nmin, max; for numbers the decimals actually used, the median and\nmax_over_median; for dates covered_days, span_days and missing_days.\nStatistics are exact and read the whole relation.\n\nExport: APP is an analysis app folder (main.js) or its entry file.\nThe app is run once, in a hidden window, and the statements its query()\ncalls issue are captured with their results. Output is one JSON object naming\nthe written file; the file itself is self-contained HTML with no JavaScript.\nExport options:\n --html Required; the only format\n --out FILE Destination; defaults to ./<app folder>.html\n --force Replace an existing destination\n --database PATH File database; must exist, opened read-only by default\n --read-write Allow database writes/creation (requires --database)\n --timeout SECONDS Capture time limit, default 15\n\nCheck: FILE is a .dash dashboard spec — query blocks holding SQL heredocs,\nplot blocks with type/query/x/y/series attributes, references like\nquery.latency between them. The check parses the file, resolves every\nreference and attribute, and validates each query's SQL with the real DuckDB\nparser; nothing executes and no table needs to exist. With --database it\nalso runs every query on that database (read-only), so an error that only\nshows once rows are read fails the check, and checks each plot's\nx/y/series against the columns the query actually returns.\nOutput: one JSON object with the file's queries and plots; a spec mistake is\nexit 2 with one line per diagnostic, a database or I/O failure is exit 1\n(a failing query is one line each, all of them).\n\nLsp: a Language Server Protocol server for .dash files, over stdio, for\neditors to spawn. Full-document sync; on every open and change it publishes\nthe same parse and semantic diagnostics `check` reports (exit-2 mistakes,\nall severity Error), plus each query's SQL through the real DuckDB parser\nwhen --database is given. Completion offers block, attribute, type and\nquery-name candidates; hover documents blocks, attributes and references;\ngo-to-definition jumps a query.name reference to its query block. Exit 0 on\na clean shutdown, 1 if the client goes away without one, 2 for a bad command\nline or a failed protocol handshake.\n";
pub(crate) const HELP: &str = "DuckLocal — local data workspace and headless SQL\n\nUsage:\n ducklocal [PATH ...] Open the GUI (files, folders, globs)\n ducklocal query --sql SQL [OPTIONS] Execute one statement, return JSON\n ducklocal query --sql-file FILE [OPTIONS]\n ducklocal profile TARGET [--database PATH] Per-column statistics, JSON\n ducklocal export --html [OPTIONS] APP App data as a standalone HTML file\n ducklocal check FILE [--database PATH] Validate a .dash dashboard spec\n ducklocal lsp [--database PATH] Language server for .dash files (stdio)\n ducklocal --help\n ducklocal --version\n\nQuery options:\n --sql SQL SQL text; exactly one of --sql and --sql-file is required\n --sql-file FILE UTF-8 SQL file; - reads stdin\n --database PATH File database; must exist, opened read-only by default\n --read-write Allow database writes/creation (requires --database)\n --limit N Maximum returned rows, default 1000; positive integer\n --format FORMAT json (default) or md, a Markdown table to read and quote\n --help Show this help\n\nOutput: one JSON object with columns, rows, row_count, truncated, elapsed_ms.\nColumn types are Arrow debug names, not SQL type names. A 2,000,000-cell\nbudget also applies. A scan stops at the limit; ORDER BY, GROUP BY and\naggregates still compute over every row first. --format md\nrenders the same values as readable text: dates and timestamps in ISO form,\nDECIMALs with their digits, NULL as NULL. It is a rendering, not the contract;\nuse JSON where a caller parses the result.\nErrors: JSON on stderr, empty stdout; exit 2 for arguments, 1 for SQL/I/O.\nRead-only is NOT a filesystem/network sandbox: COPY can write files.\nExtensions are not automatically installed. GUI state/history is not used.\nA GUI path named `query`, `profile`, `export`, `check`, `dash` or `lsp` must be written ./query, ./profile, ./export, ./check, ./dash, ./lsp.\n\nProfile: TARGET is a data file (csv/tsv/parquet/json) or a workbook\n(xlsx/xls/xlsb/ods; its first sheet is imported and profiled), or, with\n--database, a table or view name. Per column it reports type, nulls, distinct,\nmin, max; for numbers the decimals actually used, the median and\nmax_over_median; for dates covered_days, span_days and missing_days.\nStatistics are exact and read the whole relation.\n\nExport: APP is an analysis app folder (main.js) or its entry file.\nThe app is run once, in a hidden window, and the statements its query()\ncalls issue are captured with their results. Output is one JSON object naming\nthe written file; the file itself is self-contained HTML with no JavaScript.\nExport options:\n --html Required; the only format\n --out FILE Destination; defaults to ./<app folder>.html\n --force Replace an existing destination\n --database PATH File database; must exist, opened read-only by default\n --read-write Allow database writes/creation (requires --database)\n --timeout SECONDS Capture time limit, default 15\n\nCheck: FILE is a .dash dashboard spec — query blocks holding SQL heredocs,\nplot blocks with type/query/x/y/series attributes, references like\nquery.latency between them. The check parses the file, resolves every\nreference and attribute, and validates each query's SQL with the real DuckDB\nparser; nothing executes and no table needs to exist. With --database it\nalso runs every query on that database (read-only), so an error that only\nshows once rows are read fails the check, and checks each plot's\nx/y/series against the columns the query actually returns.\nOutput: one JSON object with the file's queries and plots; a spec mistake is\nexit 2 with one line per diagnostic, a database or I/O failure is exit 1\n(a failing query is one line each, all of them).\n\nLsp: a Language Server Protocol server for .dash files, over stdio, for\neditors to spawn. Full-document sync; on every open and change it publishes\nthe same parse and semantic diagnostics `check` reports (exit-2 mistakes,\nall severity Error), plus each query's SQL through the real DuckDB parser\nwhen --database is given. Completion offers block, attribute, type and\nquery-name candidates; hover documents blocks, attributes and references;\ngo-to-definition jumps a query.name reference to its query block. Exit 0 on\na clean shutdown, 1 if the client goes away without one, 2 for a bad command\nline or a failed protocol handshake.\n";

#[derive(Debug)]
pub(crate) struct CliError {
Expand Down
Loading