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
4,138 changes: 2,490 additions & 1,648 deletions Cargo.lock

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ humantime-serde = "1.1.1"
lazy_static = "1.5.0"
log = "0.4.22"
nix = { version = "0.28.0", features = ["signal", "process", "term"] }
nu-protocol = { version = "0.101.0" }
nu-cmd-extra = { version = "0.101.0" }
nu-cmd-lang = { version = "0.101.0" }
nu-cmd-plugin = { version = "0.101.0" }
nu-command = { version = "0.101.0", features = ["plugin"] }
nu-explore = { version = "0.101.0" }
nu-parser = { version = "0.101.0" }
nu-path = { version = "0.101.0" }
nu-cli = { version = "0.101.0", features = ["plugin"] }
nu-engine = { version = "0.101.0" }
nu-plugin = { version = "0.101.0" }
nu-plugin-engine = { version = "0.101.0" }
nu-system = { version = "0.101.0" }
nu-utils = "0.101.0"
nu-protocol = { version = "0.107" }
nu-cmd-extra = { version = "0.107" }
nu-cmd-lang = { version = "0.107" }
nu-cmd-plugin = { version = "0.107" }
nu-command = { version = "0.107", features = ["plugin"] }
nu-explore = { version = "0.107" }
nu-parser = { version = "0.107" }
nu-path = { version = "0.107" }
nu-cli = { version = "0.107", features = ["plugin"] }
nu-engine = { version = "0.107" }
nu-plugin = { version = "0.107" }
nu-plugin-engine = { version = "0.107" }
nu-system = { version = "0.107" }
nu-utils = "0.107"
rand = "0.8.5"
regex = "1.10.5"
reqwest = { version = "0.12.5", features = ["json", "rustls-tls", "blocking"] }
Expand Down
3 changes: 1 addition & 2 deletions docs/sample_config/default_config.nu
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ export def build_collection_prompt [] {
$"($scope_name + $col_name)"
}

let prompt = $"('👤 ' + (ansi ub) + ($user) + (ansi reset) + ' 🏠 ' + (ansi yb) + ($cluster) + (ansi reset) + ($bucket_prompt) + ($collection_prompt) + (ansi reset))

let prompt = $"('👤 ' + (ansi bb) + ($user) + (ansi reset) + ' 🏠 ' + (ansi yb) + ($cluster) + (ansi reset) + ($bucket_prompt) + ($collection_prompt) + (ansi reset))
"

$prompt
Expand Down
1 change: 0 additions & 1 deletion docs/sample_config/default_config_windows.nu
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export def build_collection_prompt [] {
}

let prompt = $"(($user) + ' at ' + ($cluster) + ($bucket_prompt) + ($collection_prompt))

"

$prompt
Expand Down
4 changes: 1 addition & 3 deletions docs/sample_config/prompt_tests.nu
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ use std assert
# Mock the cb-env command used by build_collection_prompt
def cb-env [] {{display_name: my-name cluster: my-cluster bucket: my-bucket scope: my-scope collection: my-collection cluster_type: provisioned}}
let prompt = build_collection_prompt
let expected_prompt = $"('👤 ' + (ansi ub) + 'my-name' + (ansi reset) + ' 🏠 ' + (ansi yb) + 'my-cluster' + (ansi reset) + ' in ☁️ ' + (ansi wb) + 'my-bucket.my-scope.my-collection' + (ansi reset))

let expected_prompt = $"('👤 ' + (ansi bb) + 'my-name' + (ansi reset) + ' 🏠 ' + (ansi yb) + 'my-cluster' + (ansi reset) + ' in ☁️ ' + (ansi wb) + 'my-bucket.my-scope.my-collection' + (ansi reset))
"
assert equal ($prompt) $expected_prompt

use default_config_windows.nu build_collection_prompt
let prompt = build_collection_prompt
let expected_windows_prompt = $"('my-name' + ' at ' + 'my-cluster' + ' in ' + 'my-bucket.my-scope.my-collection')

"
assert equal ($prompt) $expected_windows_prompt
10 changes: 5 additions & 5 deletions query_autocomplete/fields.nu
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ export def main [context: string] {
# If they contain an operator then we split the condition on that operator and return the first word, this will be the name of the field
let $fields_in_conditions = ($conditions | each {|cond| $cli_operators | each {|op| if ($cond | str contains $op) {$cond | split row $op | first | str trim} } | first})
let $collection = ($context | split words | $in.1)
return { options: {sort: false}, completions: (collection_fields $collection | get fields | filter {|x| $x not-in $fields_in_conditions} | prepend [ANY EVERY])}
return { options: {sort: false}, completions: (collection_fields $collection | get fields | where {|x| $x not-in $fields_in_conditions} | prepend [ANY EVERY])}
}
ANY => {return}
EVERY => {return}
IN => {
let $collection = ($context | split words | $in.1)
let $array_fields = (collection_fields $collection| filter {|it| $it.type == array} | get fields)
let $array_fields = (collection_fields $collection| where {|it| $it.type == array} | get fields)
# There is an issue with the nushell completions where nothing is displayed if all the completions start the same
# So we append an empty space to the list of array fields to work around this for now
return { options: {sort: false}, completions: ($array_fields | append " ")}
Expand Down Expand Up @@ -120,7 +120,7 @@ export def main [context: string] {

# WHERE x #operator y
# If an operator has been given after where but is not the last, then suggest AND
if (($after_last_keyword | split row " " | filter {|x| $x in $cli_operators} | length) != 0) {
if (($after_last_keyword | split row " " | where {|x| $x in $cli_operators} | length) != 0) {
let $select_fields = ($context | split row SELECT | last | split row WHERE | first | str trim)
if ($select_fields == "*") {
return [AND LIMIT]
Expand All @@ -139,7 +139,7 @@ export def main [context: string] {
}

# If an operator has been given after AND but is not the last, then suggest AND LIMIT
if (($after_last_keyword | split row " " | filter {|x| $x in $cli_operators} | length) != 0) {
if (($after_last_keyword | split row " " | where {|x| $x in $cli_operators} | length) != 0) {
# To do - should check if all fields have been used in conditions, if so only suggest LIMIT
return [AND LIMIT]
}
Expand All @@ -157,7 +157,7 @@ export def main [context: string] {
}

# `Satisfies person.age <operator> <value> ` => END
if (($after_last_keyword | split row " " | filter {|x| $x in $cli_operators} | length) != 0) {
if (($after_last_keyword | split row " " | where {|x| $x in $cli_operators} | length) != 0) {
return [END]
}

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
# The default profile includes rustc, rust-std, cargo, rust-docs, rustfmt and clippy.
# https://rust-lang.github.io/rustup/concepts/profiles.html
profile = "default"
channel = "1.85"
channel = "1.88"
37 changes: 7 additions & 30 deletions src/cli/analytics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use nu_protocol::{
Category, IntoPipelineData, ListStream, PipelineData, ShellError, Signature, Span, SyntaxShape,
Value,
};
use nu_utils::SharedCow;
use std::str::from_utf8;
use std::sync::{Arc, Mutex};
use tokio::runtime::Runtime;
Expand Down Expand Up @@ -96,10 +95,7 @@ impl Iterator for AnalyticsStream {
let bytes = match result {
Ok(r) => r,
Err(e) => {
return Some(Value::Error {
error: Box::new(e),
internal_span: self.span,
});
return Some(Value::error(e, self.span));
}
};
let result_string = from_utf8(&bytes).unwrap();
Expand Down Expand Up @@ -199,26 +195,11 @@ fn run(
let meta_value = convert_json_value_to_nu_value(&meta_json, span).unwrap();
let meta_as_record: &mut nu_protocol::Record = &mut meta_value.into_record().unwrap();

meta_as_record.push(
"cluster",
Value::String {
val: identifier.clone(),
internal_span: span,
},
);

meta_as_record.push(
"results",
Value::List {
vals: query_results,
internal_span: span,
},
);

results.push(Value::Record {
val: SharedCow::new(meta_as_record.clone()),
internal_span: span,
})
meta_as_record.push("cluster", Value::string(identifier.clone(), span));

meta_as_record.push("results", Value::list(query_results, span));

results.push(Value::record(meta_as_record.clone(), span))
}

streams.insert(identifier, json_streamer);
Expand All @@ -227,11 +208,7 @@ fn run(
let result_stream = AnalyticsStream { streams, span, rt };

if with_meta {
return Ok(Value::List {
vals: results,
internal_span: span,
}
.into_pipeline_data());
return Ok(Value::list(results, span).into_pipeline_data());
}

Ok(PipelineData::from(ListStream::new(
Expand Down
6 changes: 1 addition & 5 deletions src/cli/analytics_buckets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,5 @@ fn dataverses(
)?);
}

Ok(Value::List {
vals: results,
internal_span: span,
}
.into_pipeline_data())
Ok(Value::list(results, span).into_pipeline_data())
}
6 changes: 1 addition & 5 deletions src/cli/analytics_datasets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,5 @@ fn datasets(
)?);
}

Ok(Value::List {
vals: results,
internal_span: span,
}
.into_pipeline_data())
Ok(Value::list(results, span).into_pipeline_data())
}
6 changes: 1 addition & 5 deletions src/cli/analytics_dataverses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,5 @@ fn dataverses(
)?);
}

Ok(Value::List {
vals: results,
internal_span: span,
}
.into_pipeline_data())
Ok(Value::list(results, span).into_pipeline_data())
}
6 changes: 1 addition & 5 deletions src/cli/analytics_indexes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,5 @@ fn indexes(
)?);
}

Ok(Value::List {
vals: results,
internal_span: span,
}
.into_pipeline_data())
Ok(Value::list(results, span).into_pipeline_data())
}
6 changes: 1 addition & 5 deletions src/cli/analytics_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,5 @@ fn links(
)?);
}

Ok(Value::List {
vals: results,
internal_span: span,
}
.into_pipeline_data())
Ok(Value::list(results, span).into_pipeline_data())
}
6 changes: 1 addition & 5 deletions src/cli/analytics_pending_mutations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,5 @@ fn pending_mutations(
results.append(converted);
}

Ok(Value::List {
vals: results,
internal_span: span,
}
.into_pipeline_data())
Ok(Value::list(results, span).into_pipeline_data())
}
7 changes: 2 additions & 5 deletions src/cli/ask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"Asks a connected LLM a question, optionally enhanced with context"
}

fn examples(&self) -> Vec<Example> {

Check warning on line 54 in src/cli/ask.rs

View workflow job for this annotation

GitHub Actions / test (7.0.3, ubuntu-24.04)

hiding a lifetime that's elided elsewhere is confusing

Check warning on line 54 in src/cli/ask.rs

View workflow job for this annotation

GitHub Actions / test (7.1.1, ubuntu-24.04)

hiding a lifetime that's elided elsewhere is confusing
vec![
Example {
description: "Ask a simple question",
Expand Down Expand Up @@ -94,6 +94,7 @@
Value::List {
vals,
internal_span: span,
..
} => {
let mut ctx: Vec<String> = Vec::new();
for v in vals {
Expand Down Expand Up @@ -192,9 +193,5 @@
}
};

Ok(Value::String {
val: answer,
internal_span: span,
}
.into_pipeline_data())
Ok(Value::string(answer, span).into_pipeline_data())
}
6 changes: 1 addition & 5 deletions src/cli/buckets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,7 @@ fn buckets_get_all(
}
}

Ok(Value::List {
vals: results,
internal_span: span,
}
.into_pipeline_data())
Ok(Value::list(results, span).into_pipeline_data())
}

pub fn get_buckets(
Expand Down
14 changes: 5 additions & 9 deletions src/cli/buckets_get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,7 @@ fn buckets_get(
));
}

Ok(Value::List {
vals: results,
internal_span: call.head,
}
.into_pipeline_data())
Ok(Value::list(results, call.head).into_pipeline_data())
}

pub fn get_server_bucket(
Expand Down Expand Up @@ -175,10 +171,10 @@ pub(crate) fn bucket_to_nu_value(
);
collected.add(
"ram_quota",
Value::Filesize {
val: Filesize::new((bucket.ram_quota_mb() * 1024 * 1024) as i64),
internal_span: span,
},
Value::filesize(
Filesize::new((bucket.ram_quota_mb() * 1024 * 1024) as i64),
span,
),
);
collected.add_bool("flush_enabled", bucket.flush_enabled(), span);
collected.add_bool("cloud", is_cloud, span);
Expand Down
6 changes: 1 addition & 5 deletions src/cli/buckets_sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,7 @@ fn load_sample_bucket(
results.push(collected.into_value(span));
}

Ok(Value::List {
vals: results,
internal_span: span,
}
.into_pipeline_data())
Ok(Value::list(results, span).into_pipeline_data())
}

fn load_sever_sample(
Expand Down
10 changes: 2 additions & 8 deletions src/cli/cbenv_bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use crate::state::State;
use nu_engine::command_prelude::Call;
use nu_engine::CallExt;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::Value::Nothing;
use nu_protocol::{Category, PipelineData, ShellError, Signature, SyntaxShape};
use nu_protocol::{Category, PipelineData, ShellError, Signature, SyntaxShape, Value};
use std::sync::{Arc, Mutex};

#[derive(Clone)]
Expand Down Expand Up @@ -62,11 +61,6 @@ impl Command for UseBucket {
active.set_active_collection(None);
}

Ok(PipelineData::Value(
Nothing {
internal_span: span,
},
None,
))
Ok(PipelineData::Value(Value::nothing(span), None))
}
}
10 changes: 2 additions & 8 deletions src/cli/cbenv_capella_organization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use std::sync::{Arc, Mutex};
use nu_engine::command_prelude::Call;
use nu_engine::CallExt;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::Value::Nothing;
use nu_protocol::{Category, PipelineData, ShellError, Signature, SyntaxShape};
use nu_protocol::{Category, PipelineData, ShellError, Signature, SyntaxShape, Value};

#[derive(Clone)]
pub struct UseCapellaOrganization {
Expand Down Expand Up @@ -47,11 +46,6 @@ impl Command for UseCapellaOrganization {
let guard = self.state.lock().unwrap();
guard.set_active_capella_org(call.req(engine_state, stack, 0)?)?;

Ok(PipelineData::Value(
Nothing {
internal_span: call.head,
},
None,
))
Ok(PipelineData::Value(Value::nothing(call.head), None))
}
}
10 changes: 2 additions & 8 deletions src/cli/cbenv_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use std::sync::{Arc, Mutex};
use nu_engine::command_prelude::Call;
use nu_engine::CallExt;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::Value::Nothing;
use nu_protocol::{Category, PipelineData, ShellError, Signature, SyntaxShape};
use nu_protocol::{Category, PipelineData, ShellError, Signature, SyntaxShape, Value};

#[derive(Clone)]
pub struct CbEnvCluster {
Expand Down Expand Up @@ -47,11 +46,6 @@ impl Command for CbEnvCluster {
let guard = self.state.lock().unwrap();
guard.set_active(call.req(engine_state, stack, 0)?)?;

Ok(PipelineData::Value(
Nothing {
internal_span: call.head,
},
None,
))
Ok(PipelineData::Value(Value::nothing(call.head), None))
}
}
Loading
Loading