diff --git a/prqlc/prqlc/src/cli/docs_generator.rs b/prqlc/prqlc/src/cli/docs_generator.rs new file mode 100644 index 000000000000..03d996b7f1dc --- /dev/null +++ b/prqlc/prqlc/src/cli/docs_generator.rs @@ -0,0 +1,430 @@ +use prqlc_ast::{stmt::StmtKind, ExprKind, Stmt, TyKind, VarDefKind}; + +/// Generate HTML documentation. +// pub fn generate_html_docs(stmts: Vec) -> String { +// let html = format!( +// r#" +// +// +// +// +// +// +// +// PRQL Docs +// +// +//
+//
+//

Documentation

+//
+//
+//
+// {{{{ content }}}} +//
+// +// +// +// "#, +// *prqlc::COMPILER_VERSION, +// *prqlc::COMPILER_VERSION +// ); + +// let mut docs = String::new(); + +// docs.push_str("

Functions

\n"); +// docs.push_str("\n\n"); +// if stmts +// .clone() +// .into_iter() +// .filter(|stmt| matches!(stmt.kind, StmtKind::VarDef(_))) +// .count() +// == 0 +// { +// docs.push_str("

None.

\n\n"); +// } + +// if stmts +// .clone() +// .into_iter() +// .filter(|stmt| matches!(stmt.kind, StmtKind::TypeDef(_))) +// .count() +// > 0 +// { +// docs.push_str("

Types

\n"); +// docs.push_str("\n"); +// } + +// if stmts +// .clone() +// .into_iter() +// .filter(|stmt| matches!(stmt.kind, StmtKind::ModuleDef(_))) +// .count() +// > 0 +// { +// docs.push_str("

Modules

\n"); +// docs.push_str("\n"); +// } + +// for stmt in stmts +// .clone() +// .into_iter() +// .filter(|stmt| matches!(stmt.kind, StmtKind::VarDef(_))) +// { +// let var_def = stmt.kind.as_var_def().unwrap(); +// if var_def.kind != VarDefKind::Let { +// continue; +// } + +// docs.push_str("
\n"); +// docs.push_str(&format!( +// "

{}

\n", +// var_def.name, var_def.name +// )); + +// //if let Some(docComment) = vardef.DocComment { +// // docs.push_str(&format!("

{docComment}

\n")); +// //} + +// if let Some(expr) = &var_def.value { +// match &expr.kind { +// ExprKind::Func(func) => { +// docs.push_str("

Parameters

\n"); +// docs.push_str(" \n"); + +// if let Some(return_ty) = &func.return_ty { +// docs.push_str("

Returns

\n"); +// match &return_ty.kind { +// TyKind::Any => docs.push_str("

Any

\n"), +// TyKind::Ident(ident) => { +// docs.push_str(&format!("

{}

\n", ident.name)); +// } +// TyKind::Primitive(primitive) => { +// docs.push_str(&format!("

{primitive}

\n")); +// } +// TyKind::Singleton(literal) => { +// docs.push_str(&format!("

{literal}

\n")); +// } +// TyKind::Union(vec) => { +// docs.push_str(" \n"); +// } +// _ => docs.push_str("

Not implemented

\n"), +// } +// } +// } +// ExprKind::Pipeline(_) => { +// docs.push_str("

There is a pipeline.

\n"); +// } +// _ => (), +// } +// } + +// docs.push_str("
\n"); +// } + +// html.replacen("{{ content }}", &docs, 1) +// } + +/// Generate Markdown documentation. +pub fn generate_markdown_docs(stmts: Vec) -> String { + let markdown = format!( + r#"# Documentation + +{{{{ content }}}} + +Generated with [prqlc](https://prql-lang.org/) {}. +"#, + *prqlc::COMPILER_VERSION + ); + + let mut docs = String::new(); + + docs.push_str("## Functions\n"); + for stmt in stmts + .clone() + .into_iter() + .filter(|stmt| matches!(stmt.kind, StmtKind::VarDef(_))) + { + let var_def = stmt.kind.as_var_def().unwrap(); + docs.push_str(&format!("* [{}](#{})\n", var_def.name, var_def.name)); + } + docs.push('\n'); + + if stmts + .clone() + .into_iter() + .filter(|stmt| matches!(stmt.kind, StmtKind::VarDef(_))) + .count() + == 0 + { + docs.push_str("None.\n\n"); + } + + if stmts + .clone() + .into_iter() + .filter(|stmt| matches!(stmt.kind, StmtKind::TypeDef(_))) + .count() + > 0 + { + docs.push_str("## Types\n"); + for stmt in stmts + .clone() + .into_iter() + .filter(|stmt| matches!(stmt.kind, StmtKind::TypeDef(_))) + { + let type_def = stmt.kind.as_type_def().unwrap(); + if let Some(value) = &type_def.value { + docs.push_str(&format!("* `{}` – {:?}\n", type_def.name, value.kind)); + } else { + docs.push_str(&format!("* {}\n", type_def.name)); + } + } + docs.push('\n'); + } + + if stmts + .clone() + .into_iter() + .filter(|stmt| matches!(stmt.kind, StmtKind::ModuleDef(_))) + .count() + > 0 + { + docs.push_str("## Modules\n"); + for stmt in stmts + .clone() + .into_iter() + .filter(|stmt| matches!(stmt.kind, StmtKind::ModuleDef(_))) + { + let module_def = stmt.kind.as_module_def().unwrap(); + docs.push_str(&format!("* {}\n", module_def.name)); + } + docs.push('\n'); + } + + for stmt in stmts + .clone() + .into_iter() + .filter(|stmt| matches!(stmt.kind, StmtKind::VarDef(_))) + { + let var_def = stmt.kind.as_var_def().unwrap(); + if var_def.kind != VarDefKind::Let { + continue; + } + + docs.push_str(&format!("### {}\n", var_def.name)); + + //if let Some(docComment) = vardef.DocComment { + // docs.push_str(&format!("{docComment}\n")); + //} + docs.push('\n'); + + if let Some(expr) = &var_def.value { + match &expr.kind { + ExprKind::Func(func) => { + docs.push_str("#### Parameters\n"); + for param in &func.params { + docs.push_str(&format!("* *{}*\n", param.name)); + } + docs.push('\n'); + + if let Some(return_ty) = &func.return_ty { + docs.push_str("#### Returns\n"); + match &return_ty.kind { + TyKind::Any => docs.push_str("Any\n"), + TyKind::Ident(ident) => { + docs.push_str(&format!("`{}`\n", ident.name)); + } + TyKind::Primitive(primitive) => { + docs.push_str(&format!("`{primitive}`\n")); + } + TyKind::Singleton(literal) => { + docs.push_str(&format!("`{literal}`\n")); + } + TyKind::Union(vec) => { + for (_, ty) in vec { + docs.push_str(&format!("* {:?}\n", ty.kind)); + } + } + _ => docs.push_str("Not implemented\n"), + } + } + docs.push('\n'); + } + ExprKind::Pipeline(_) => { + docs.push_str("There is a pipeline.\n"); + } + _ => (), + } + } + } + + markdown.replacen("{{ content }}", &docs, 1) +} + +#[cfg(test)] +mod tests { + use insta_cmd::assert_cmd_snapshot; + use insta_cmd::get_cargo_bin; + use std::process::Command; + + #[test] + fn generate_markdown_docs() { + let input = r" + let x = arg1 arg2 -> c + let fn_returns_array = -> array + let fn_returns_bool = -> true + let fn_returns_float = -> float + let fn_returns_int = -> 0 + let fn_returns_null = -> null + let fn_returns_text = -> 'text' + + module foo {} + + type user_id = int + "; + + assert_cmd_snapshot!(prqlc_command().args(["experimental", "doc"]).pass_stdin(input), @r###" + success: true + exit_code: 0 + ----- stdout ----- + # Documentation + + ## Functions + * [x](#x) + * [fn_returns_array](#fn_returns_array) + * [fn_returns_bool](#fn_returns_bool) + * [fn_returns_float](#fn_returns_float) + * [fn_returns_int](#fn_returns_int) + * [fn_returns_null](#fn_returns_null) + * [fn_returns_text](#fn_returns_text) + + ## Types + * `user_id` – Primitive(Int) + + ## Modules + * foo + + ### x + + #### Parameters + * *arg1* + * *arg2* + + + ### fn_returns_array + + #### Parameters + + #### Returns + `array` + + ### fn_returns_bool + + #### Parameters + + #### Returns + `bool` + + ### fn_returns_float + + #### Parameters + + #### Returns + `float` + + ### fn_returns_int + + #### Parameters + + #### Returns + `int` + + ### fn_returns_null + + #### Parameters + + #### Returns + `null` + + ### fn_returns_text + + #### Parameters + + #### Returns + `text` + + + + Generated with [prqlc](https://prql-lang.org/) 0.11.3. + + ----- stderr ----- + "###); + } + + fn prqlc_command() -> Command { + let mut cmd = Command::new(get_cargo_bin("prqlc")); + normalize_prqlc(&mut cmd); + cmd + } + + fn normalize_prqlc(cmd: &mut Command) -> &mut Command { + cmd + // We set `CLICOLOR_FORCE` in CI to force color output, but we don't want `prqlc` to + // output color for our snapshot tests. And it seems to override the + // `--color=never` flag. + .env_remove("CLICOLOR_FORCE") + .env("NO_COLOR", "1") + .args(["--color=never"]) + // We don't want the tests to be affected by the user's `RUST_BACKTRACE` setting. + .env_remove("RUST_BACKTRACE") + .env_remove("RUST_LOG") + } +} diff --git a/prqlc/prqlc/src/cli/mod.rs b/prqlc/prqlc/src/cli/mod.rs index c6a6227ffb0b..8d012ab4a732 100644 --- a/prqlc/prqlc/src/cli/mod.rs +++ b/prqlc/prqlc/src/cli/mod.rs @@ -1,5 +1,6 @@ #![cfg(not(target_family = "wasm"))] +mod docs_generator; mod jinja; mod watch; @@ -93,6 +94,9 @@ enum Command { #[command(subcommand)] Debug(DebugCommand), + #[command(subcommand)] + Experimental(ExperimentalCommand), + /// Parse, resolve & lower into RQ Resolve { #[command(flatten)] @@ -175,6 +179,14 @@ pub enum DebugCommand { Ast, } +/// Experimental commands are prone to change +#[derive(Subcommand, Debug, Clone)] +pub enum ExperimentalCommand { + /// Generate Markdown documentation + #[command(name = "doc")] + GenerateDocs(IoArgs), +} + #[derive(clap::Args, Default, Debug, Clone)] pub struct IoArgs { #[arg(value_parser, default_value = "-", value_hint(ValueHint::AnyPath))] @@ -373,6 +385,12 @@ impl Command { res.into_bytes() } + Command::Experimental(ExperimentalCommand::GenerateDocs(_)) => { + let stmts = prql_to_pl_tree(sources)?; + + let stmts = stmts.sources.values().next().unwrap().to_vec(); + docs_generator::generate_markdown_docs(stmts).into_bytes() + } Command::Resolve { format, .. } => { semantic::load_std_lib(sources); @@ -440,7 +458,9 @@ impl Command { // `input`, rather than matching on them and grabbing `input` from // `self`? But possibly if everything moves to `io_args`, then this is // quite reasonable? - use Command::{Collect, Debug, Parse, Resolve, SQLAnchor, SQLCompile, SQLPreprocess}; + use Command::{ + Collect, Debug, Experimental, Parse, Resolve, SQLAnchor, SQLCompile, SQLPreprocess, + }; let io_args = match self { Parse { io_args, .. } | Collect(io_args) @@ -454,6 +474,7 @@ impl Command { | DebugCommand::Annotate(io_args) | DebugCommand::Eval(io_args), ) => io_args, + Experimental(ExperimentalCommand::GenerateDocs(io_args)) => io_args, _ => unreachable!(), }; let input = &mut io_args.input; @@ -480,7 +501,9 @@ impl Command { } fn write_output(&mut self, data: &[u8]) -> std::io::Result<()> { - use Command::{Collect, Debug, Parse, Resolve, SQLAnchor, SQLCompile, SQLPreprocess}; + use Command::{ + Collect, Debug, Experimental, Parse, Resolve, SQLAnchor, SQLCompile, SQLPreprocess, + }; let mut output = match self { Parse { io_args, .. } | Collect(io_args) @@ -494,6 +517,7 @@ impl Command { | DebugCommand::Annotate(io_args) | DebugCommand::Eval(io_args), ) => io_args.output.clone(), + Experimental(ExperimentalCommand::GenerateDocs(io_args)) => io_args.output.clone(), _ => unreachable!(), }; output.write_all(data) diff --git a/prqlc/prqlc/tests/integration/cli.rs b/prqlc/prqlc/tests/integration/cli.rs index eb9f021fb7d4..6bc371607ea0 100644 --- a/prqlc/prqlc/tests/integration/cli.rs +++ b/prqlc/prqlc/tests/integration/cli.rs @@ -20,6 +20,7 @@ fn help() { fmt Parse & generate PRQL code back collect Parse the whole project and collect it into a single PRQL source file debug Commands for meant for debugging, prone to change + experimental Experimental commands are prone to change resolve Parse, resolve & lower into RQ sql:preprocess Parse, resolve, lower into RQ & preprocess SRQ sql:anchor Parse, resolve, lower into RQ & preprocess & anchor SRQ diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__cli__shell_completion-2.snap b/prqlc/prqlc/tests/integration/snapshots/integration__cli__shell_completion-2.snap index caaf8ecb997b..9ddc2403e69d 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__cli__shell_completion-2.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__cli__shell_completion-2.snap @@ -7,10 +7,10 @@ info: - shell-completion - fish env: - RUST_BACKTRACE: "" - RUST_LOG: "" CLICOLOR_FORCE: "" NO_COLOR: "1" + RUST_BACKTRACE: "" + RUST_LOG: "" --- success: true exit_code: 0 @@ -22,6 +22,7 @@ complete -c prqlc -n "__fish_use_subcommand" -f -a "parse" -d 'Parse into PL AST complete -c prqlc -n "__fish_use_subcommand" -f -a "fmt" -d 'Parse & generate PRQL code back' complete -c prqlc -n "__fish_use_subcommand" -f -a "collect" -d 'Parse the whole project and collect it into a single PRQL source file' complete -c prqlc -n "__fish_use_subcommand" -f -a "debug" -d 'Commands for meant for debugging, prone to change' +complete -c prqlc -n "__fish_use_subcommand" -f -a "experimental" -d 'Experimental commands are prone to change' complete -c prqlc -n "__fish_use_subcommand" -f -a "resolve" -d 'Parse, resolve & lower into RQ' complete -c prqlc -n "__fish_use_subcommand" -f -a "sql:preprocess" -d 'Parse, resolve, lower into RQ & preprocess SRQ' complete -c prqlc -n "__fish_use_subcommand" -f -a "sql:anchor" -d 'Parse, resolve, lower into RQ & preprocess & anchor SRQ' @@ -61,6 +62,14 @@ complete -c prqlc -n "__fish_seen_subcommand_from debug; and __fish_seen_subcomm complete -c prqlc -n "__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from help; and not __fish_seen_subcommand_from expand-pl; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast; and not __fish_seen_subcommand_from help" -f -a "annotate" -d 'Parse, resolve & combine source with comments annotating relation type' complete -c prqlc -n "__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from help; and not __fish_seen_subcommand_from expand-pl; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast; and not __fish_seen_subcommand_from help" -f -a "ast" -d 'Print info about the AST data structure' complete -c prqlc -n "__fish_seen_subcommand_from debug; and __fish_seen_subcommand_from help; and not __fish_seen_subcommand_from expand-pl; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)' +complete -c prqlc -n "__fish_seen_subcommand_from experimental; and not __fish_seen_subcommand_from doc; and not __fish_seen_subcommand_from help" -l color -d 'Controls when to use color' -r -f -a "{auto '',always '',never ''}" +complete -c prqlc -n "__fish_seen_subcommand_from experimental; and not __fish_seen_subcommand_from doc; and not __fish_seen_subcommand_from help" -s h -l help -d 'Print help' +complete -c prqlc -n "__fish_seen_subcommand_from experimental; and not __fish_seen_subcommand_from doc; and not __fish_seen_subcommand_from help" -f -a "doc" -d 'Generate Markdown documentation' +complete -c prqlc -n "__fish_seen_subcommand_from experimental; and not __fish_seen_subcommand_from doc; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)' +complete -c prqlc -n "__fish_seen_subcommand_from experimental; and __fish_seen_subcommand_from doc" -l color -d 'Controls when to use color' -r -f -a "{auto '',always '',never ''}" +complete -c prqlc -n "__fish_seen_subcommand_from experimental; and __fish_seen_subcommand_from doc" -s h -l help -d 'Print help' +complete -c prqlc -n "__fish_seen_subcommand_from experimental; and __fish_seen_subcommand_from help; and not __fish_seen_subcommand_from doc; and not __fish_seen_subcommand_from help" -f -a "doc" -d 'Generate Markdown documentation' +complete -c prqlc -n "__fish_seen_subcommand_from experimental; and __fish_seen_subcommand_from help; and not __fish_seen_subcommand_from doc; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)' complete -c prqlc -n "__fish_seen_subcommand_from resolve" -l format -r -f -a "{json '',yaml ''}" complete -c prqlc -n "__fish_seen_subcommand_from resolve" -l color -d 'Controls when to use color' -r -f -a "{auto '',always '',never ''}" complete -c prqlc -n "__fish_seen_subcommand_from resolve" -s h -l help -d 'Print help' @@ -82,23 +91,25 @@ complete -c prqlc -n "__fish_seen_subcommand_from list-targets" -l color -d 'Con complete -c prqlc -n "__fish_seen_subcommand_from list-targets" -s h -l help -d 'Print help' complete -c prqlc -n "__fish_seen_subcommand_from shell-completion" -l color -d 'Controls when to use color' -r -f -a "{auto '',always '',never ''}" complete -c prqlc -n "__fish_seen_subcommand_from shell-completion" -s h -l help -d 'Print help' -complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "parse" -d 'Parse into PL AST' -complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "fmt" -d 'Parse & generate PRQL code back' -complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "collect" -d 'Parse the whole project and collect it into a single PRQL source file' -complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "debug" -d 'Commands for meant for debugging, prone to change' -complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "resolve" -d 'Parse, resolve & lower into RQ' -complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "sql:preprocess" -d 'Parse, resolve, lower into RQ & preprocess SRQ' -complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "sql:anchor" -d 'Parse, resolve, lower into RQ & preprocess & anchor SRQ' -complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "compile" -d 'Parse, resolve, lower into RQ & compile to SQL' -complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "watch" -d 'Watch a directory and compile .prql files to .sql files' -complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "list-targets" -d 'Show available compile target names' -complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "shell-completion" -d 'Print a shell completion for supported shells' -complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)' +complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from experimental; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "parse" -d 'Parse into PL AST' +complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from experimental; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "fmt" -d 'Parse & generate PRQL code back' +complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from experimental; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "collect" -d 'Parse the whole project and collect it into a single PRQL source file' +complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from experimental; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "debug" -d 'Commands for meant for debugging, prone to change' +complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from experimental; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "experimental" -d 'Experimental commands are prone to change' +complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from experimental; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "resolve" -d 'Parse, resolve & lower into RQ' +complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from experimental; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "sql:preprocess" -d 'Parse, resolve, lower into RQ & preprocess SRQ' +complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from experimental; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "sql:anchor" -d 'Parse, resolve, lower into RQ & preprocess & anchor SRQ' +complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from experimental; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "compile" -d 'Parse, resolve, lower into RQ & compile to SQL' +complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from experimental; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "watch" -d 'Watch a directory and compile .prql files to .sql files' +complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from experimental; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "list-targets" -d 'Show available compile target names' +complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from experimental; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "shell-completion" -d 'Print a shell completion for supported shells' +complete -c prqlc -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from parse; and not __fish_seen_subcommand_from fmt; and not __fish_seen_subcommand_from collect; and not __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from experimental; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from sql:preprocess; and not __fish_seen_subcommand_from sql:anchor; and not __fish_seen_subcommand_from compile; and not __fish_seen_subcommand_from watch; and not __fish_seen_subcommand_from list-targets; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)' complete -c prqlc -n "__fish_seen_subcommand_from help; and __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from expand-pl; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast" -f -a "expand-pl" -d 'Parse & and expand into PL, but don\'t resolve' complete -c prqlc -n "__fish_seen_subcommand_from help; and __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from expand-pl; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast" -f -a "resolve" -d 'Parse & resolve, but don\'t lower into RQ' complete -c prqlc -n "__fish_seen_subcommand_from help; and __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from expand-pl; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast" -f -a "eval" -d 'Parse & evaluate expression down to a value' complete -c prqlc -n "__fish_seen_subcommand_from help; and __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from expand-pl; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast" -f -a "annotate" -d 'Parse, resolve & combine source with comments annotating relation type' complete -c prqlc -n "__fish_seen_subcommand_from help; and __fish_seen_subcommand_from debug; and not __fish_seen_subcommand_from expand-pl; and not __fish_seen_subcommand_from resolve; and not __fish_seen_subcommand_from eval; and not __fish_seen_subcommand_from annotate; and not __fish_seen_subcommand_from ast" -f -a "ast" -d 'Print info about the AST data structure' +complete -c prqlc -n "__fish_seen_subcommand_from help; and __fish_seen_subcommand_from experimental; and not __fish_seen_subcommand_from doc" -f -a "doc" -d 'Generate Markdown documentation' ----- stderr ----- diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__cli__shell_completion-3.snap b/prqlc/prqlc/tests/integration/snapshots/integration__cli__shell_completion-3.snap index 2c4e6c7109c1..3fc55fbf0aaa 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__cli__shell_completion-3.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__cli__shell_completion-3.snap @@ -9,8 +9,8 @@ info: env: NO_COLOR: "1" CLICOLOR_FORCE: "" - RUST_BACKTRACE: "" RUST_LOG: "" + RUST_BACKTRACE: "" --- success: true exit_code: 0 @@ -47,6 +47,7 @@ Register-ArgumentCompleter -Native -CommandName 'prqlc' -ScriptBlock { [CompletionResult]::new('fmt', 'fmt', [CompletionResultType]::ParameterValue, 'Parse & generate PRQL code back') [CompletionResult]::new('collect', 'collect', [CompletionResultType]::ParameterValue, 'Parse the whole project and collect it into a single PRQL source file') [CompletionResult]::new('debug', 'debug', [CompletionResultType]::ParameterValue, 'Commands for meant for debugging, prone to change') + [CompletionResult]::new('experimental', 'experimental', [CompletionResultType]::ParameterValue, 'Experimental commands are prone to change') [CompletionResult]::new('resolve', 'resolve', [CompletionResultType]::ParameterValue, 'Parse, resolve & lower into RQ') [CompletionResult]::new('sql:preprocess', 'sql:preprocess', [CompletionResultType]::ParameterValue, 'Parse, resolve, lower into RQ & preprocess SRQ') [CompletionResult]::new('sql:anchor', 'sql:anchor', [CompletionResultType]::ParameterValue, 'Parse, resolve, lower into RQ & preprocess & anchor SRQ') @@ -145,6 +146,31 @@ Register-ArgumentCompleter -Native -CommandName 'prqlc' -ScriptBlock { 'prqlc;debug;help;help' { break } + 'prqlc;experimental' { + [CompletionResult]::new('--color', 'color', [CompletionResultType]::ParameterName, 'Controls when to use color') + [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('doc', 'doc', [CompletionResultType]::ParameterValue, 'Generate Markdown documentation') + [CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)') + break + } + 'prqlc;experimental;doc' { + [CompletionResult]::new('--color', 'color', [CompletionResultType]::ParameterName, 'Controls when to use color') + [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help') + [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help') + break + } + 'prqlc;experimental;help' { + [CompletionResult]::new('doc', 'doc', [CompletionResultType]::ParameterValue, 'Generate Markdown documentation') + [CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)') + break + } + 'prqlc;experimental;help;doc' { + break + } + 'prqlc;experimental;help;help' { + break + } 'prqlc;resolve' { [CompletionResult]::new('--format', 'format', [CompletionResultType]::ParameterName, 'format') [CompletionResult]::new('--color', 'color', [CompletionResultType]::ParameterName, 'Controls when to use color') @@ -200,6 +226,7 @@ Register-ArgumentCompleter -Native -CommandName 'prqlc' -ScriptBlock { [CompletionResult]::new('fmt', 'fmt', [CompletionResultType]::ParameterValue, 'Parse & generate PRQL code back') [CompletionResult]::new('collect', 'collect', [CompletionResultType]::ParameterValue, 'Parse the whole project and collect it into a single PRQL source file') [CompletionResult]::new('debug', 'debug', [CompletionResultType]::ParameterValue, 'Commands for meant for debugging, prone to change') + [CompletionResult]::new('experimental', 'experimental', [CompletionResultType]::ParameterValue, 'Experimental commands are prone to change') [CompletionResult]::new('resolve', 'resolve', [CompletionResultType]::ParameterValue, 'Parse, resolve & lower into RQ') [CompletionResult]::new('sql:preprocess', 'sql:preprocess', [CompletionResultType]::ParameterValue, 'Parse, resolve, lower into RQ & preprocess SRQ') [CompletionResult]::new('sql:anchor', 'sql:anchor', [CompletionResultType]::ParameterValue, 'Parse, resolve, lower into RQ & preprocess & anchor SRQ') @@ -242,6 +269,13 @@ Register-ArgumentCompleter -Native -CommandName 'prqlc' -ScriptBlock { 'prqlc;help;debug;ast' { break } + 'prqlc;help;experimental' { + [CompletionResult]::new('doc', 'doc', [CompletionResultType]::ParameterValue, 'Generate Markdown documentation') + break + } + 'prqlc;help;experimental;doc' { + break + } 'prqlc;help;resolve' { break } diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__cli__shell_completion-4.snap b/prqlc/prqlc/tests/integration/snapshots/integration__cli__shell_completion-4.snap index 836e46897704..2de4acf50ab4 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__cli__shell_completion-4.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__cli__shell_completion-4.snap @@ -8,9 +8,9 @@ info: - zsh env: RUST_BACKTRACE: "" + RUST_LOG: "" CLICOLOR_FORCE: "" NO_COLOR: "1" - RUST_LOG: "" --- success: true exit_code: 0 @@ -181,6 +181,59 @@ esac ;; esac ;; +(experimental) +_arguments "${_arguments_options[@]}" \ +'--color=[Controls when to use color]:WHEN:(auto always never)' \ +'-h[Print help]' \ +'--help[Print help]' \ +":: :_prqlc__experimental_commands" \ +"*::: :->experimental" \ +&& ret=0 + + case $state in + (experimental) + words=($line[1] "${words[@]}") + (( CURRENT += 1 )) + curcontext="${curcontext%:*:*}:prqlc-experimental-command-$line[1]:" + case $line[1] in + (doc) +_arguments "${_arguments_options[@]}" \ +'--color=[Controls when to use color]:WHEN:(auto always never)' \ +'-h[Print help]' \ +'--help[Print help]' \ +'::input:_files' \ +'::output:_files' \ +'::main_path -- Identifier of the main pipeline:' \ +&& ret=0 +;; +(help) +_arguments "${_arguments_options[@]}" \ +":: :_prqlc__experimental__help_commands" \ +"*::: :->help" \ +&& ret=0 + + case $state in + (help) + words=($line[1] "${words[@]}") + (( CURRENT += 1 )) + curcontext="${curcontext%:*:*}:prqlc-experimental-help-command-$line[1]:" + case $line[1] in + (doc) +_arguments "${_arguments_options[@]}" \ +&& ret=0 +;; +(help) +_arguments "${_arguments_options[@]}" \ +&& ret=0 +;; + esac + ;; +esac +;; + esac + ;; +esac +;; (resolve) _arguments "${_arguments_options[@]}" \ '--format=[]:FORMAT:(json yaml)' \ @@ -312,6 +365,26 @@ _arguments "${_arguments_options[@]}" \ ;; esac ;; +(experimental) +_arguments "${_arguments_options[@]}" \ +":: :_prqlc__help__experimental_commands" \ +"*::: :->experimental" \ +&& ret=0 + + case $state in + (experimental) + words=($line[1] "${words[@]}") + (( CURRENT += 1 )) + curcontext="${curcontext%:*:*}:prqlc-help-experimental-command-$line[1]:" + case $line[1] in + (doc) +_arguments "${_arguments_options[@]}" \ +&& ret=0 +;; + esac + ;; +esac +;; (resolve) _arguments "${_arguments_options[@]}" \ && ret=0 @@ -360,6 +433,7 @@ _prqlc_commands() { 'fmt:Parse & generate PRQL code back' \ 'collect:Parse the whole project and collect it into a single PRQL source file' \ 'debug:Commands for meant for debugging, prone to change' \ +'experimental:Experimental commands are prone to change' \ 'resolve:Parse, resolve & lower into RQ' \ 'sql:preprocess:Parse, resolve, lower into RQ & preprocess SRQ' \ 'sql:anchor:Parse, resolve, lower into RQ & preprocess & anchor SRQ' \ @@ -444,6 +518,21 @@ _prqlc__help__debug_commands() { ) _describe -t commands 'prqlc help debug commands' commands "$@" } +(( $+functions[_prqlc__experimental__doc_commands] )) || +_prqlc__experimental__doc_commands() { + local commands; commands=() + _describe -t commands 'prqlc experimental doc commands' commands "$@" +} +(( $+functions[_prqlc__experimental__help__doc_commands] )) || +_prqlc__experimental__help__doc_commands() { + local commands; commands=() + _describe -t commands 'prqlc experimental help doc commands' commands "$@" +} +(( $+functions[_prqlc__help__experimental__doc_commands] )) || +_prqlc__help__experimental__doc_commands() { + local commands; commands=() + _describe -t commands 'prqlc help experimental doc commands' commands "$@" +} (( $+functions[_prqlc__debug__eval_commands] )) || _prqlc__debug__eval_commands() { local commands; commands=() @@ -474,6 +563,21 @@ _prqlc__help__debug__expand-pl_commands() { local commands; commands=() _describe -t commands 'prqlc help debug expand-pl commands' commands "$@" } +(( $+functions[_prqlc__experimental_commands] )) || +_prqlc__experimental_commands() { + local commands; commands=( +'doc:Generate Markdown documentation' \ +'help:Print this message or the help of the given subcommand(s)' \ + ) + _describe -t commands 'prqlc experimental commands' commands "$@" +} +(( $+functions[_prqlc__help__experimental_commands] )) || +_prqlc__help__experimental_commands() { + local commands; commands=( +'doc:Generate Markdown documentation' \ + ) + _describe -t commands 'prqlc help experimental commands' commands "$@" +} (( $+functions[_prqlc__fmt_commands] )) || _prqlc__fmt_commands() { local commands; commands=() @@ -501,6 +605,19 @@ _prqlc__debug__help__help_commands() { local commands; commands=() _describe -t commands 'prqlc debug help help commands' commands "$@" } +(( $+functions[_prqlc__experimental__help_commands] )) || +_prqlc__experimental__help_commands() { + local commands; commands=( +'doc:Generate Markdown documentation' \ +'help:Print this message or the help of the given subcommand(s)' \ + ) + _describe -t commands 'prqlc experimental help commands' commands "$@" +} +(( $+functions[_prqlc__experimental__help__help_commands] )) || +_prqlc__experimental__help__help_commands() { + local commands; commands=() + _describe -t commands 'prqlc experimental help help commands' commands "$@" +} (( $+functions[_prqlc__help_commands] )) || _prqlc__help_commands() { local commands; commands=( @@ -508,6 +625,7 @@ _prqlc__help_commands() { 'fmt:Parse & generate PRQL code back' \ 'collect:Parse the whole project and collect it into a single PRQL source file' \ 'debug:Commands for meant for debugging, prone to change' \ +'experimental:Experimental commands are prone to change' \ 'resolve:Parse, resolve & lower into RQ' \ 'sql:preprocess:Parse, resolve, lower into RQ & preprocess SRQ' \ 'sql:anchor:Parse, resolve, lower into RQ & preprocess & anchor SRQ' \ diff --git a/prqlc/prqlc/tests/integration/snapshots/integration__cli__shell_completion.snap b/prqlc/prqlc/tests/integration/snapshots/integration__cli__shell_completion.snap index 599edd7ca3f0..81ce9642849a 100644 --- a/prqlc/prqlc/tests/integration/snapshots/integration__cli__shell_completion.snap +++ b/prqlc/prqlc/tests/integration/snapshots/integration__cli__shell_completion.snap @@ -7,9 +7,9 @@ info: - shell-completion - bash env: + RUST_BACKTRACE: "" CLICOLOR_FORCE: "" NO_COLOR: "1" - RUST_BACKTRACE: "" RUST_LOG: "" --- success: true @@ -38,6 +38,9 @@ _prqlc() { prqlc,debug) cmd="prqlc__debug" ;; + prqlc,experimental) + cmd="prqlc__experimental" + ;; prqlc,fmt) cmd="prqlc__fmt" ;; @@ -101,6 +104,18 @@ _prqlc() { prqlc__debug__help,resolve) cmd="prqlc__debug__help__resolve" ;; + prqlc__experimental,doc) + cmd="prqlc__experimental__doc" + ;; + prqlc__experimental,help) + cmd="prqlc__experimental__help" + ;; + prqlc__experimental__help,doc) + cmd="prqlc__experimental__help__doc" + ;; + prqlc__experimental__help,help) + cmd="prqlc__experimental__help__help" + ;; prqlc__help,collect) cmd="prqlc__help__collect" ;; @@ -110,6 +125,9 @@ _prqlc() { prqlc__help,debug) cmd="prqlc__help__debug" ;; + prqlc__help,experimental) + cmd="prqlc__help__experimental" + ;; prqlc__help,fmt) cmd="prqlc__help__fmt" ;; @@ -152,6 +170,9 @@ _prqlc() { prqlc__help__debug,resolve) cmd="prqlc__help__debug__resolve" ;; + prqlc__help__experimental,doc) + cmd="prqlc__help__experimental__doc" + ;; *) ;; esac @@ -159,7 +180,7 @@ _prqlc() { case "${cmd}" in prqlc) - opts="-h -V --color --help --version parse fmt collect debug resolve sql:preprocess sql:anchor compile watch list-targets shell-completion help" + opts="-h -V --color --help --version parse fmt collect debug experimental resolve sql:preprocess sql:anchor compile watch list-targets shell-completion help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -426,6 +447,84 @@ _prqlc() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; + prqlc__experimental) + opts="-h --color --help doc help" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + --color) + COMPREPLY=($(compgen -W "auto always never" -- "${cur}")) + return 0 + ;; + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + prqlc__experimental__doc) + opts="-h --color --help [INPUT] [OUTPUT] [MAIN_PATH]" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + --color) + COMPREPLY=($(compgen -W "auto always never" -- "${cur}")) + return 0 + ;; + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + prqlc__experimental__help) + opts="doc help" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + prqlc__experimental__help__doc) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + prqlc__experimental__help__help) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; prqlc__fmt) opts="-h --color --help [INPUT]" if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then @@ -445,7 +544,7 @@ _prqlc() { return 0 ;; prqlc__help) - opts="parse fmt collect debug resolve sql:preprocess sql:anchor compile watch list-targets shell-completion help" + opts="parse fmt collect debug experimental resolve sql:preprocess sql:anchor compile watch list-targets shell-completion help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -570,6 +669,34 @@ _prqlc() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; + prqlc__help__experimental) + opts="doc" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; + prqlc__help__experimental__doc) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; prqlc__help__fmt) opts="" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then