merging main

This commit is contained in:
Jack Wright 2024-06-25 16:59:45 -07:00
commit 8f4f705a7c
54 changed files with 542 additions and 340 deletions

74
Cargo.lock generated
View File

@ -2798,7 +2798,7 @@ dependencies = [
[[package]]
name = "nu"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"assert_cmd",
"crossterm",
@ -2851,7 +2851,7 @@ dependencies = [
[[package]]
name = "nu-cli"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"chrono",
"crossterm",
@ -2886,7 +2886,7 @@ dependencies = [
[[package]]
name = "nu-cmd-base"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"indexmap",
"miette",
@ -2898,7 +2898,7 @@ dependencies = [
[[package]]
name = "nu-cmd-extra"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"fancy-regex",
"heck 0.5.0",
@ -2923,7 +2923,7 @@ dependencies = [
[[package]]
name = "nu-cmd-lang"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"itertools 0.12.1",
"nu-engine",
@ -2935,7 +2935,7 @@ dependencies = [
[[package]]
name = "nu-cmd-plugin"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"itertools 0.12.1",
"nu-engine",
@ -2946,7 +2946,7 @@ dependencies = [
[[package]]
name = "nu-color-config"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"nu-ansi-term",
"nu-engine",
@ -2958,7 +2958,7 @@ dependencies = [
[[package]]
name = "nu-command"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"alphanumeric-sort",
"base64 0.22.1",
@ -3067,7 +3067,7 @@ dependencies = [
[[package]]
name = "nu-derive-value"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"convert_case",
"proc-macro-error",
@ -3078,7 +3078,7 @@ dependencies = [
[[package]]
name = "nu-engine"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"nu-glob",
"nu-path",
@ -3088,7 +3088,7 @@ dependencies = [
[[package]]
name = "nu-explore"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"ansi-str",
"anyhow",
@ -3113,14 +3113,14 @@ dependencies = [
[[package]]
name = "nu-glob"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"doc-comment",
]
[[package]]
name = "nu-json"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"linked-hash-map",
"num-traits",
@ -3130,7 +3130,7 @@ dependencies = [
[[package]]
name = "nu-lsp"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"assert-json-diff",
"crossbeam-channel",
@ -3151,7 +3151,7 @@ dependencies = [
[[package]]
name = "nu-parser"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"bytesize",
"chrono",
@ -3167,7 +3167,7 @@ dependencies = [
[[package]]
name = "nu-path"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"dirs-next",
"omnipath",
@ -3176,7 +3176,7 @@ dependencies = [
[[package]]
name = "nu-plugin"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"log",
"nix",
@ -3191,7 +3191,7 @@ dependencies = [
[[package]]
name = "nu-plugin-core"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"interprocess",
"log",
@ -3205,7 +3205,7 @@ dependencies = [
[[package]]
name = "nu-plugin-engine"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"log",
"nu-engine",
@ -3220,7 +3220,7 @@ dependencies = [
[[package]]
name = "nu-plugin-protocol"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"bincode",
"nu-protocol",
@ -3232,7 +3232,7 @@ dependencies = [
[[package]]
name = "nu-plugin-test-support"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"nu-ansi-term",
"nu-cmd-lang",
@ -3250,7 +3250,7 @@ dependencies = [
[[package]]
name = "nu-pretty-hex"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"heapless",
"nu-ansi-term",
@ -3259,7 +3259,7 @@ dependencies = [
[[package]]
name = "nu-protocol"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"brotli",
"byte-unit",
@ -3292,7 +3292,7 @@ dependencies = [
[[package]]
name = "nu-std"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"log",
"miette",
@ -3303,7 +3303,7 @@ dependencies = [
[[package]]
name = "nu-system"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"chrono",
"itertools 0.12.1",
@ -3321,7 +3321,7 @@ dependencies = [
[[package]]
name = "nu-table"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"fancy-regex",
"nu-ansi-term",
@ -3335,7 +3335,7 @@ dependencies = [
[[package]]
name = "nu-term-grid"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"nu-utils",
"unicode-width",
@ -3343,7 +3343,7 @@ dependencies = [
[[package]]
name = "nu-test-support"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"nu-glob",
"nu-path",
@ -3355,7 +3355,7 @@ dependencies = [
[[package]]
name = "nu-utils"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"crossterm_winapi",
"log",
@ -3381,7 +3381,7 @@ dependencies = [
[[package]]
name = "nu_plugin_example"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"nu-cmd-lang",
"nu-plugin",
@ -3391,7 +3391,7 @@ dependencies = [
[[package]]
name = "nu_plugin_formats"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"eml-parser",
"ical",
@ -3404,7 +3404,7 @@ dependencies = [
[[package]]
name = "nu_plugin_gstat"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"git2",
"nu-plugin",
@ -3413,7 +3413,7 @@ dependencies = [
[[package]]
name = "nu_plugin_inc"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"nu-plugin",
"nu-protocol",
@ -3422,7 +3422,7 @@ dependencies = [
[[package]]
name = "nu_plugin_polars"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"chrono",
"chrono-tz 0.9.0",
@ -3456,7 +3456,7 @@ dependencies = [
[[package]]
name = "nu_plugin_query"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"gjson",
"nu-plugin",
@ -3468,7 +3468,7 @@ dependencies = [
[[package]]
name = "nu_plugin_stress_internals"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"interprocess",
"serde",
@ -3594,7 +3594,7 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3"
[[package]]
name = "nuon"
version = "0.94.3"
version = "0.95.0"
dependencies = [
"chrono",
"fancy-regex",

View File

@ -11,7 +11,7 @@ license = "MIT"
name = "nu"
repository = "https://github.com/nushell/nushell"
rust-version = "1.77.2"
version = "0.94.3"
version = "0.95.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -180,22 +180,22 @@ windows = "0.54"
winreg = "0.52"
[dependencies]
nu-cli = { path = "./crates/nu-cli", version = "0.94.3" }
nu-cmd-base = { path = "./crates/nu-cmd-base", version = "0.94.3" }
nu-cmd-lang = { path = "./crates/nu-cmd-lang", version = "0.94.3" }
nu-cmd-plugin = { path = "./crates/nu-cmd-plugin", version = "0.94.3", optional = true }
nu-cmd-extra = { path = "./crates/nu-cmd-extra", version = "0.94.3" }
nu-command = { path = "./crates/nu-command", version = "0.94.3" }
nu-engine = { path = "./crates/nu-engine", version = "0.94.3" }
nu-explore = { path = "./crates/nu-explore", version = "0.94.3" }
nu-lsp = { path = "./crates/nu-lsp/", version = "0.94.3" }
nu-parser = { path = "./crates/nu-parser", version = "0.94.3" }
nu-path = { path = "./crates/nu-path", version = "0.94.3" }
nu-plugin-engine = { path = "./crates/nu-plugin-engine", optional = true, version = "0.94.3" }
nu-protocol = { path = "./crates/nu-protocol", version = "0.94.3" }
nu-std = { path = "./crates/nu-std", version = "0.94.3" }
nu-system = { path = "./crates/nu-system", version = "0.94.3" }
nu-utils = { path = "./crates/nu-utils", version = "0.94.3" }
nu-cli = { path = "./crates/nu-cli", version = "0.95.0" }
nu-cmd-base = { path = "./crates/nu-cmd-base", version = "0.95.0" }
nu-cmd-lang = { path = "./crates/nu-cmd-lang", version = "0.95.0" }
nu-cmd-plugin = { path = "./crates/nu-cmd-plugin", version = "0.95.0", optional = true }
nu-cmd-extra = { path = "./crates/nu-cmd-extra", version = "0.95.0" }
nu-command = { path = "./crates/nu-command", version = "0.95.0" }
nu-engine = { path = "./crates/nu-engine", version = "0.95.0" }
nu-explore = { path = "./crates/nu-explore", version = "0.95.0" }
nu-lsp = { path = "./crates/nu-lsp/", version = "0.95.0" }
nu-parser = { path = "./crates/nu-parser", version = "0.95.0" }
nu-path = { path = "./crates/nu-path", version = "0.95.0" }
nu-plugin-engine = { path = "./crates/nu-plugin-engine", optional = true, version = "0.95.0" }
nu-protocol = { path = "./crates/nu-protocol", version = "0.95.0" }
nu-std = { path = "./crates/nu-std", version = "0.95.0" }
nu-system = { path = "./crates/nu-system", version = "0.95.0" }
nu-utils = { path = "./crates/nu-utils", version = "0.95.0" }
reedline = { workspace = true, features = ["bashisms", "sqlite"] }
@ -225,9 +225,9 @@ nix = { workspace = true, default-features = false, features = [
] }
[dev-dependencies]
nu-test-support = { path = "./crates/nu-test-support", version = "0.94.3" }
nu-plugin-protocol = { path = "./crates/nu-plugin-protocol", version = "0.94.3" }
nu-plugin-core = { path = "./crates/nu-plugin-core", version = "0.94.3" }
nu-test-support = { path = "./crates/nu-test-support", version = "0.95.0" }
nu-plugin-protocol = { path = "./crates/nu-plugin-protocol", version = "0.95.0" }
nu-plugin-core = { path = "./crates/nu-plugin-core", version = "0.95.0" }
assert_cmd = "2.0"
dirs-next = { workspace = true }
tango-bench = "0.5"
@ -310,4 +310,4 @@ bench = false
# Run individual benchmarks like `cargo bench -- <regex>` e.g. `cargo bench -- parse`
[[bench]]
name = "benchmarks"
harness = false
harness = false

View File

@ -5,27 +5,27 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cli"
edition = "2021"
license = "MIT"
name = "nu-cli"
version = "0.94.3"
version = "0.95.0"
[lib]
bench = false
[dev-dependencies]
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.94.3" }
nu-command = { path = "../nu-command", version = "0.94.3" }
nu-test-support = { path = "../nu-test-support", version = "0.94.3" }
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.95.0" }
nu-command = { path = "../nu-command", version = "0.95.0" }
nu-test-support = { path = "../nu-test-support", version = "0.95.0" }
rstest = { workspace = true, default-features = false }
tempfile = { workspace = true }
[dependencies]
nu-cmd-base = { path = "../nu-cmd-base", version = "0.94.3" }
nu-engine = { path = "../nu-engine", version = "0.94.3" }
nu-path = { path = "../nu-path", version = "0.94.3" }
nu-parser = { path = "../nu-parser", version = "0.94.3" }
nu-plugin-engine = { path = "../nu-plugin-engine", version = "0.94.3", optional = true }
nu-protocol = { path = "../nu-protocol", version = "0.94.3" }
nu-utils = { path = "../nu-utils", version = "0.94.3" }
nu-color-config = { path = "../nu-color-config", version = "0.94.3" }
nu-cmd-base = { path = "../nu-cmd-base", version = "0.95.0" }
nu-engine = { path = "../nu-engine", version = "0.95.0" }
nu-path = { path = "../nu-path", version = "0.95.0" }
nu-parser = { path = "../nu-parser", version = "0.95.0" }
nu-plugin-engine = { path = "../nu-plugin-engine", version = "0.95.0", optional = true }
nu-protocol = { path = "../nu-protocol", version = "0.95.0" }
nu-utils = { path = "../nu-utils", version = "0.95.0" }
nu-color-config = { path = "../nu-color-config", version = "0.95.0" }
nu-ansi-term = { workspace = true }
reedline = { workspace = true, features = ["bashisms", "sqlite"] }
@ -46,4 +46,4 @@ which = { workspace = true }
[features]
plugin = ["nu-plugin-engine"]
system-clipboard = ["reedline/system_clipboard"]
system-clipboard = ["reedline/system_clipboard"]

View File

@ -5,17 +5,17 @@ edition = "2021"
license = "MIT"
name = "nu-cmd-base"
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-base"
version = "0.94.3"
version = "0.95.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
nu-engine = { path = "../nu-engine", version = "0.94.3" }
nu-parser = { path = "../nu-parser", version = "0.94.3" }
nu-path = { path = "../nu-path", version = "0.94.3" }
nu-protocol = { path = "../nu-protocol", version = "0.94.3" }
nu-engine = { path = "../nu-engine", version = "0.95.0" }
nu-parser = { path = "../nu-parser", version = "0.95.0" }
nu-path = { path = "../nu-path", version = "0.95.0" }
nu-protocol = { path = "../nu-protocol", version = "0.95.0" }
indexmap = { workspace = true }
miette = { workspace = true }
[dev-dependencies]
[dev-dependencies]

View File

@ -5,7 +5,7 @@ edition = "2021"
license = "MIT"
name = "nu-cmd-extra"
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-extra"
version = "0.94.3"
version = "0.95.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -13,13 +13,13 @@ version = "0.94.3"
bench = false
[dependencies]
nu-cmd-base = { path = "../nu-cmd-base", version = "0.94.3" }
nu-engine = { path = "../nu-engine", version = "0.94.3" }
nu-json = { version = "0.94.3", path = "../nu-json" }
nu-parser = { path = "../nu-parser", version = "0.94.3" }
nu-pretty-hex = { version = "0.94.3", path = "../nu-pretty-hex" }
nu-protocol = { path = "../nu-protocol", version = "0.94.3" }
nu-utils = { path = "../nu-utils", version = "0.94.3" }
nu-cmd-base = { path = "../nu-cmd-base", version = "0.95.0" }
nu-engine = { path = "../nu-engine", version = "0.95.0" }
nu-json = { version = "0.95.0", path = "../nu-json" }
nu-parser = { path = "../nu-parser", version = "0.95.0" }
nu-pretty-hex = { version = "0.95.0", path = "../nu-pretty-hex" }
nu-protocol = { path = "../nu-protocol", version = "0.95.0" }
nu-utils = { path = "../nu-utils", version = "0.95.0" }
# Potential dependencies for extras
heck = { workspace = true }
@ -33,6 +33,6 @@ v_htmlescape = { workspace = true }
itertools = { workspace = true }
[dev-dependencies]
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.94.3" }
nu-command = { path = "../nu-command", version = "0.94.3" }
nu-test-support = { path = "../nu-test-support", version = "0.94.3" }
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.95.0" }
nu-command = { path = "../nu-command", version = "0.95.0" }
nu-test-support = { path = "../nu-test-support", version = "0.95.0" }

View File

@ -6,16 +6,16 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-lang"
edition = "2021"
license = "MIT"
name = "nu-cmd-lang"
version = "0.94.3"
version = "0.95.0"
[lib]
bench = false
[dependencies]
nu-engine = { path = "../nu-engine", version = "0.94.3" }
nu-parser = { path = "../nu-parser", version = "0.94.3" }
nu-protocol = { path = "../nu-protocol", version = "0.94.3" }
nu-utils = { path = "../nu-utils", version = "0.94.3" }
nu-engine = { path = "../nu-engine", version = "0.95.0" }
nu-parser = { path = "../nu-parser", version = "0.95.0" }
nu-protocol = { path = "../nu-protocol", version = "0.95.0" }
nu-utils = { path = "../nu-utils", version = "0.95.0" }
itertools = { workspace = true }
shadow-rs = { version = "0.28", default-features = false }
@ -28,4 +28,4 @@ mimalloc = []
trash-support = []
sqlite = []
static-link-openssl = []
system-clipboard = []
system-clipboard = []

View File

@ -5,16 +5,16 @@ edition = "2021"
license = "MIT"
name = "nu-cmd-plugin"
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-cmd-plugin"
version = "0.94.3"
version = "0.95.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
nu-engine = { path = "../nu-engine", version = "0.94.3" }
nu-path = { path = "../nu-path", version = "0.94.3" }
nu-protocol = { path = "../nu-protocol", version = "0.94.3", features = ["plugin"] }
nu-plugin-engine = { path = "../nu-plugin-engine", version = "0.94.3" }
nu-engine = { path = "../nu-engine", version = "0.95.0" }
nu-path = { path = "../nu-path", version = "0.95.0" }
nu-protocol = { path = "../nu-protocol", version = "0.95.0", features = ["plugin"] }
nu-plugin-engine = { path = "../nu-plugin-engine", version = "0.95.0" }
itertools = { workspace = true }
[dev-dependencies]
[dev-dependencies]

View File

@ -5,18 +5,18 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-color-confi
edition = "2021"
license = "MIT"
name = "nu-color-config"
version = "0.94.3"
version = "0.95.0"
[lib]
bench = false
[dependencies]
nu-protocol = { path = "../nu-protocol", version = "0.94.3" }
nu-engine = { path = "../nu-engine", version = "0.94.3" }
nu-json = { path = "../nu-json", version = "0.94.3" }
nu-protocol = { path = "../nu-protocol", version = "0.95.0" }
nu-engine = { path = "../nu-engine", version = "0.95.0" }
nu-json = { path = "../nu-json", version = "0.95.0" }
nu-ansi-term = { workspace = true }
serde = { workspace = true, features = ["derive"] }
[dev-dependencies]
nu-test-support = { path = "../nu-test-support", version = "0.94.3" }
nu-test-support = { path = "../nu-test-support", version = "0.95.0" }

View File

@ -5,7 +5,7 @@ edition = "2021"
license = "MIT"
name = "nu-command"
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-command"
version = "0.94.3"
version = "0.95.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -13,21 +13,21 @@ version = "0.94.3"
bench = false
[dependencies]
nu-cmd-base = { path = "../nu-cmd-base", version = "0.94.3" }
nu-color-config = { path = "../nu-color-config", version = "0.94.3" }
nu-engine = { path = "../nu-engine", version = "0.94.3" }
nu-glob = { path = "../nu-glob", version = "0.94.3" }
nu-json = { path = "../nu-json", version = "0.94.3" }
nu-parser = { path = "../nu-parser", version = "0.94.3" }
nu-path = { path = "../nu-path", version = "0.94.3" }
nu-pretty-hex = { path = "../nu-pretty-hex", version = "0.94.3" }
nu-protocol = { path = "../nu-protocol", version = "0.94.3" }
nu-system = { path = "../nu-system", version = "0.94.3" }
nu-table = { path = "../nu-table", version = "0.94.3" }
nu-term-grid = { path = "../nu-term-grid", version = "0.94.3" }
nu-utils = { path = "../nu-utils", version = "0.94.3" }
nu-cmd-base = { path = "../nu-cmd-base", version = "0.95.0" }
nu-color-config = { path = "../nu-color-config", version = "0.95.0" }
nu-engine = { path = "../nu-engine", version = "0.95.0" }
nu-glob = { path = "../nu-glob", version = "0.95.0" }
nu-json = { path = "../nu-json", version = "0.95.0" }
nu-parser = { path = "../nu-parser", version = "0.95.0" }
nu-path = { path = "../nu-path", version = "0.95.0" }
nu-pretty-hex = { path = "../nu-pretty-hex", version = "0.95.0" }
nu-protocol = { path = "../nu-protocol", version = "0.95.0" }
nu-system = { path = "../nu-system", version = "0.95.0" }
nu-table = { path = "../nu-table", version = "0.95.0" }
nu-term-grid = { path = "../nu-term-grid", version = "0.95.0" }
nu-utils = { path = "../nu-utils", version = "0.95.0" }
nu-ansi-term = { workspace = true }
nuon = { path = "../nuon", version = "0.94.3" }
nuon = { path = "../nuon", version = "0.95.0" }
alphanumeric-sort = { workspace = true }
base64 = { workspace = true }
@ -136,8 +136,8 @@ sqlite = ["rusqlite"]
trash-support = ["trash"]
[dev-dependencies]
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.94.3" }
nu-test-support = { path = "../nu-test-support", version = "0.94.3" }
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.95.0" }
nu-test-support = { path = "../nu-test-support", version = "0.95.0" }
dirs-next = { workspace = true }
mockito = { workspace = true, default-features = false }
@ -145,4 +145,4 @@ quickcheck = { workspace = true }
quickcheck_macros = { workspace = true }
rstest = { workspace = true, default-features = false }
pretty_assertions = { workspace = true }
tempfile = { workspace = true }
tempfile = { workspace = true }

View File

@ -1,6 +1,7 @@
use chrono::{Datelike, Local, NaiveDate};
use nu_color_config::StyleComputer;
use nu_engine::command_prelude::*;
use nu_protocol::ast::{Expr, Expression};
use std::collections::VecDeque;
@ -14,6 +15,7 @@ struct Arguments {
month_names: bool,
full_year: Option<Spanned<i64>>,
week_start: Option<Spanned<String>>,
as_table: bool,
}
impl Command for Cal {
@ -26,6 +28,7 @@ impl Command for Cal {
.switch("year", "Display the year column", Some('y'))
.switch("quarter", "Display the quarter column", Some('q'))
.switch("month", "Display the month column", Some('m'))
.switch("as-table", "output as a table", Some('t'))
.named(
"full-year",
SyntaxShape::Int,
@ -43,7 +46,10 @@ impl Command for Cal {
"Display the month names instead of integers",
None,
)
.input_output_types(vec![(Type::Nothing, Type::table())])
.input_output_types(vec![
(Type::Nothing, Type::table()),
(Type::Nothing, Type::String),
])
.allow_variants_without_examples(true) // TODO: supply exhaustive examples
.category(Category::Generators)
}
@ -75,10 +81,15 @@ impl Command for Cal {
result: None,
},
Example {
description: "This month's calendar with the week starting on monday",
description: "This month's calendar with the week starting on Monday",
example: "cal --week-start mo",
result: None,
},
Example {
description: "How many 'Friday the Thirteenths' occurred in 2015?",
example: "cal --as-table --full-year 2015 | where fr == 13 | length",
result: None,
},
]
}
}
@ -101,6 +112,7 @@ pub fn cal(
quarter: call.has_flag(engine_state, stack, "quarter")?,
full_year: call.get_flag(engine_state, stack, "full-year")?,
week_start: call.get_flag(engine_state, stack, "week-start")?,
as_table: call.has_flag(engine_state, stack, "as-table")?,
};
let style_computer = &StyleComputer::from_config(engine_state, stack);
@ -131,7 +143,27 @@ pub fn cal(
style_computer,
)?;
Ok(Value::list(calendar_vec_deque.into_iter().collect(), tag).into_pipeline_data())
let mut table_no_index = Call::new(Span::unknown());
table_no_index.add_named((
Spanned {
item: "index".to_string(),
span: Span::unknown(),
},
None,
Some(Expression::new_unknown(
Expr::Bool(false),
Span::unknown(),
Type::Bool,
)),
));
let cal_table_output =
Value::list(calendar_vec_deque.into_iter().collect(), tag).into_pipeline_data();
if !arguments.as_table {
crate::Table.run(engine_state, stack, &table_no_index, cal_table_output)
} else {
Ok(cal_table_output)
}
}
fn get_invalid_year_shell_error(head: Span) -> ShellError {

View File

@ -12,13 +12,7 @@ impl Command for Generate {
fn signature(&self) -> Signature {
Signature::build("generate")
.input_output_types(vec![
(Type::Nothing, Type::List(Box::new(Type::Any))),
(
Type::List(Box::new(Type::Any)),
Type::List(Box::new(Type::Any)),
),
])
.input_output_types(vec![(Type::Nothing, Type::List(Box::new(Type::Any)))])
.required("initial", SyntaxShape::Any, "Initial value.")
.required(
"closure",
@ -63,23 +57,10 @@ used as the next argument to the closure, otherwise generation stops.
)),
},
Example {
example: "generate [0, 1] {|fib| {out: $fib.0, next: [$fib.1, ($fib.0 + $fib.1)]} } | first 10",
description: "Generate a stream of fibonacci numbers",
result: Some(Value::list(
vec![
Value::test_int(0),
Value::test_int(1),
Value::test_int(1),
Value::test_int(2),
Value::test_int(3),
Value::test_int(5),
Value::test_int(8),
Value::test_int(13),
Value::test_int(21),
Value::test_int(34),
],
Span::test_data(),
)),
example:
"generate [0, 1] {|fib| {out: $fib.0, next: [$fib.1, ($fib.0 + $fib.1)]} }",
description: "Generate a continuous stream of Fibonacci numbers",
result: None,
},
]
}

View File

@ -64,7 +64,9 @@ impl Command for External {
let expanded_name = match &name {
// Expand tilde and ndots on the name if it's a bare string / glob (#13000)
Value::Glob { no_expand, .. } if !*no_expand => expand_ndots(expand_tilde(&*name_str)),
Value::Glob { no_expand, .. } if !*no_expand => {
expand_ndots_safe(expand_tilde(&*name_str))
}
_ => Path::new(&*name_str).to_owned(),
};
@ -294,7 +296,7 @@ fn expand_glob(
// For an argument that doesn't include the GLOB_CHARS, just do the `expand_tilde`
// and `expand_ndots` expansion
if !arg.contains(GLOB_CHARS) {
let path = expand_ndots(expand_tilde(arg));
let path = expand_ndots_safe(expand_tilde(arg));
return Ok(vec![path.into()]);
}
@ -582,6 +584,21 @@ fn escape_cmd_argument(arg: &Spanned<OsString>) -> Result<Cow<'_, OsStr>, ShellE
}
}
/// Expand ndots, but only if it looks like it probably contains them, because there is some lossy
/// path normalization that happens.
fn expand_ndots_safe(path: impl AsRef<Path>) -> PathBuf {
let string = path.as_ref().to_string_lossy();
// Use ndots if it contains at least `...`, since that's the minimum trigger point, and don't
// use it if it contains ://, because that looks like a URL scheme and the path normalization
// will mess with that.
if string.contains("...") && !string.contains("://") {
expand_ndots(path)
} else {
path.as_ref().to_owned()
}
}
#[cfg(test)]
mod test {
use super::*;
@ -610,7 +627,7 @@ mod test {
assert_eq!(actual, expected);
let actual = expand_glob("./a.txt", cwd, Span::unknown(), &None).unwrap();
let expected: Vec<OsString> = vec![Path::new(".").join("a.txt").into()];
let expected = &["./a.txt"];
assert_eq!(actual, expected);
let actual = expand_glob("[*.txt", cwd, Span::unknown(), &None).unwrap();

View File

@ -1,8 +1,9 @@
use nu_test_support::{nu, pipeline};
// Tests against table/structured data
#[test]
fn cal_full_year() {
let actual = nu!("cal -y --full-year 2010 | first | to json -r");
let actual = nu!("cal -t -y --full-year 2010 | first | to json -r");
let first_week_2010_json =
r#"{"year":2010,"su":null,"mo":null,"tu":null,"we":null,"th":null,"fr":1,"sa":2}"#;
@ -14,7 +15,7 @@ fn cal_full_year() {
fn cal_february_2020_leap_year() {
let actual = nu!(pipeline(
r#"
cal -ym --full-year 2020 --month-names | where month == "february" | to json -r
cal --as-table -ym --full-year 2020 --month-names | where month == "february" | to json -r
"#
));
@ -27,7 +28,7 @@ fn cal_february_2020_leap_year() {
fn cal_fr_the_thirteenths_in_2015() {
let actual = nu!(pipeline(
r#"
cal --full-year 2015 | default 0 fr | where fr == 13 | length
cal --as-table --full-year 2015 | default 0 fr | where fr == 13 | length
"#
));
@ -38,7 +39,7 @@ fn cal_fr_the_thirteenths_in_2015() {
fn cal_rows_in_2020() {
let actual = nu!(pipeline(
r#"
cal --full-year 2020 | length
cal --as-table --full-year 2020 | length
"#
));
@ -49,7 +50,7 @@ fn cal_rows_in_2020() {
fn cal_week_day_start_mo() {
let actual = nu!(pipeline(
r#"
cal --full-year 2020 -m --month-names --week-start mo | where month == january | to json -r
cal --as-table --full-year 2020 -m --month-names --week-start mo | where month == january | to json -r
"#
));
@ -62,9 +63,43 @@ fn cal_week_day_start_mo() {
fn cal_sees_pipeline_year() {
let actual = nu!(pipeline(
r#"
cal --full-year 1020 | get mo | first 4 | to json -r
cal --as-table --full-year 1020 | get mo | first 4 | to json -r
"#
));
assert_eq!(actual.out, "[null,3,10,17]");
}
// Tests against default string output
#[test]
fn cal_is_string() {
let actual = nu!(pipeline(
r#"
cal | describe
"#
));
assert_eq!(actual.out, "string (stream)");
}
#[test]
fn cal_year_num_lines() {
let actual = nu!(pipeline(
r#"
cal --full-year 2024 | lines | length
"#
));
assert_eq!(actual.out, "68");
}
#[test]
fn cal_week_start_string() {
let actual = nu!(pipeline(
r#"
cal --week-start fr | lines | get 1 | split row '│' | get 2 | ansi strip | str trim
"#
));
assert_eq!(actual.out, "sa");
}

View File

@ -2,7 +2,7 @@ use nu_test_support::nu;
#[test]
fn length_columns_in_cal_table() {
let actual = nu!("cal | columns | length");
let actual = nu!("cal --as-table | columns | length");
assert_eq!(actual.out, "7");
}

View File

@ -229,6 +229,38 @@ fn external_command_escape_args() {
})
}
#[test]
fn external_command_ndots_args() {
let actual = nu!(r#"
nu --testbin cococo foo/. foo/.. foo/... foo/./bar foo/../bar foo/.../bar ./bar ../bar .../bar
"#);
assert_eq!(
actual.out,
if cfg!(windows) {
// Windows is a bit weird right now, where if ndots has to fix something it's going to
// change everything to backslashes too. Would be good to fix that
r"foo/. foo/.. foo\..\.. foo/./bar foo/../bar foo\..\..\bar ./bar ../bar ..\..\bar"
} else {
r"foo/. foo/.. foo/../.. foo/./bar foo/../bar foo/../../bar ./bar ../bar ../../bar"
}
);
}
#[test]
fn external_command_url_args() {
// If ndots is not handled correctly, we can lose the double forward slashes that are needed
// here
let actual = nu!(r#"
nu --testbin cococo http://example.com http://example.com/.../foo //foo
"#);
assert_eq!(
actual.out,
"http://example.com http://example.com/.../foo //foo"
);
}
#[test]
#[cfg_attr(
not(target_os = "linux"),

View File

@ -5,7 +5,7 @@ edition = "2021"
license = "MIT"
name = "nu-derive-value"
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-derive-value"
version = "0.94.3"
version = "0.95.0"
[lib]
proc-macro = true
@ -18,4 +18,4 @@ proc-macro2 = { workspace = true }
syn = { workspace = true }
quote = { workspace = true }
proc-macro-error = { workspace = true }
convert_case = { workspace = true }
convert_case = { workspace = true }

View File

@ -3,6 +3,7 @@ use proc_macro2::TokenStream as TokenStream2;
use quote::{quote, ToTokens};
use syn::{
spanned::Spanned, Attribute, Data, DataEnum, DataStruct, DeriveInput, Fields, Generics, Ident,
Type,
};
use crate::attributes::{self, ContainerAttributes};
@ -116,15 +117,11 @@ fn derive_struct_from_value(
/// src_span: span
/// })?,
/// )?,
/// favorite_toy: <Option<String> as nu_protocol::FromValue>::from_value(
/// record
/// .remove("favorite_toy")
/// .ok_or_else(|| nu_protocol::ShellError::CantFindColumn {
/// col_name: std::string::ToString::to_string("favorite_toy"),
/// span: std::option::Option::None,
/// src_span: span
/// })?,
/// )?,
/// favorite_toy: record
/// .remove("favorite_toy")
/// .map(|v| <#ty as nu_protocol::FromValue>::from_value(v))
/// .transpose()?
/// .flatten(),
/// })
/// }
/// }
@ -480,20 +477,29 @@ fn parse_value_via_fields(fields: &Fields, self_ident: impl ToTokens) -> TokenSt
match fields {
Fields::Named(fields) => {
let fields = fields.named.iter().map(|field| {
// TODO: handle missing fields for Options as None
let ident = field.ident.as_ref().expect("named has idents");
let ident_s = ident.to_string();
let ty = &field.ty;
quote! {
#ident: <#ty as nu_protocol::FromValue>::from_value(
record
match type_is_option(ty) {
true => quote! {
#ident: record
.remove(#ident_s)
.ok_or_else(|| nu_protocol::ShellError::CantFindColumn {
col_name: std::string::ToString::to_string(#ident_s),
span: std::option::Option::None,
src_span: span
})?,
)?
.map(|v| <#ty as nu_protocol::FromValue>::from_value(v))
.transpose()?
.flatten()
},
false => quote! {
#ident: <#ty as nu_protocol::FromValue>::from_value(
record
.remove(#ident_s)
.ok_or_else(|| nu_protocol::ShellError::CantFindColumn {
col_name: std::string::ToString::to_string(#ident_s),
span: std::option::Option::None,
src_span: span
})?,
)?
},
}
});
quote! {
@ -537,3 +543,25 @@ fn parse_value_via_fields(fields: &Fields, self_ident: impl ToTokens) -> TokenSt
},
}
}
const FULLY_QUALIFIED_OPTION: &str = "std::option::Option";
const PARTIALLY_QUALIFIED_OPTION: &str = "option::Option";
const PRELUDE_OPTION: &str = "Option";
/// Check if the field type is an `Option`.
///
/// This function checks if a given type is an `Option`.
/// We assume that an `Option` is [`std::option::Option`] because we can't see the whole code and
/// can't ask the compiler itself.
/// If the `Option` type isn't `std::option::Option`, the user will get a compile error due to a
/// type mismatch.
/// It's very unusual for people to override `Option`, so this should rarely be an issue.
///
/// When [rust#63084](https://github.com/rust-lang/rust/issues/63084) is resolved, we can use
/// [`std::any::type_name`] for a static assertion check to get a more direct error messages.
fn type_is_option(ty: &Type) -> bool {
let s = ty.to_token_stream().to_string();
s.starts_with(PRELUDE_OPTION)
|| s.starts_with(PARTIALLY_QUALIFIED_OPTION)
|| s.starts_with(FULLY_QUALIFIED_OPTION)
}

View File

@ -5,16 +5,16 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-engine"
edition = "2021"
license = "MIT"
name = "nu-engine"
version = "0.94.3"
version = "0.95.0"
[lib]
bench = false
[dependencies]
nu-protocol = { path = "../nu-protocol", features = ["plugin"], version = "0.94.3" }
nu-path = { path = "../nu-path", version = "0.94.3" }
nu-glob = { path = "../nu-glob", version = "0.94.3" }
nu-utils = { path = "../nu-utils", version = "0.94.3" }
nu-protocol = { path = "../nu-protocol", features = ["plugin"], version = "0.95.0" }
nu-path = { path = "../nu-path", version = "0.95.0" }
nu-glob = { path = "../nu-glob", version = "0.95.0" }
nu-utils = { path = "../nu-utils", version = "0.95.0" }
[features]
plugin = []
plugin = []

View File

@ -5,21 +5,21 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-explore"
edition = "2021"
license = "MIT"
name = "nu-explore"
version = "0.94.3"
version = "0.95.0"
[lib]
bench = false
[dependencies]
nu-protocol = { path = "../nu-protocol", version = "0.94.3" }
nu-parser = { path = "../nu-parser", version = "0.94.3" }
nu-color-config = { path = "../nu-color-config", version = "0.94.3" }
nu-engine = { path = "../nu-engine", version = "0.94.3" }
nu-table = { path = "../nu-table", version = "0.94.3" }
nu-json = { path = "../nu-json", version = "0.94.3" }
nu-utils = { path = "../nu-utils", version = "0.94.3" }
nu-protocol = { path = "../nu-protocol", version = "0.95.0" }
nu-parser = { path = "../nu-parser", version = "0.95.0" }
nu-color-config = { path = "../nu-color-config", version = "0.95.0" }
nu-engine = { path = "../nu-engine", version = "0.95.0" }
nu-table = { path = "../nu-table", version = "0.95.0" }
nu-json = { path = "../nu-json", version = "0.95.0" }
nu-utils = { path = "../nu-utils", version = "0.95.0" }
nu-ansi-term = { workspace = true }
nu-pretty-hex = { path = "../nu-pretty-hex", version = "0.94.3" }
nu-pretty-hex = { path = "../nu-pretty-hex", version = "0.95.0" }
anyhow = { workspace = true }
log = { workspace = true }
@ -32,4 +32,4 @@ ansi-str = { workspace = true }
unicode-width = { workspace = true }
lscolors = { workspace = true, default-features = false, features = [
"nu-ansi-term",
] }
] }

View File

@ -1,6 +1,6 @@
[package]
name = "nu-glob"
version = "0.94.3"
version = "0.95.0"
authors = ["The Nushell Project Developers", "The Rust Project Developers"]
license = "MIT/Apache-2.0"
description = """
@ -14,4 +14,4 @@ categories = ["filesystem"]
bench = false
[dev-dependencies]
doc-comment = "0.3"
doc-comment = "0.3"

View File

@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-json"
edition = "2021"
license = "MIT"
name = "nu-json"
version = "0.94.3"
version = "0.95.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -23,5 +23,5 @@ serde = { workspace = true }
serde_json = { workspace = true }
[dev-dependencies]
# nu-path = { path="../nu-path", version = "0.94.3" }
# serde_json = "1.0"
# nu-path = { path="../nu-path", version = "0.95.0" }
# serde_json = "1.0"

View File

@ -3,14 +3,14 @@ authors = ["The Nushell Project Developers"]
description = "Nushell's integrated LSP server"
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-lsp"
name = "nu-lsp"
version = "0.94.3"
version = "0.95.0"
edition = "2021"
license = "MIT"
[dependencies]
nu-cli = { path = "../nu-cli", version = "0.94.3" }
nu-parser = { path = "../nu-parser", version = "0.94.3" }
nu-protocol = { path = "../nu-protocol", version = "0.94.3" }
nu-cli = { path = "../nu-cli", version = "0.95.0" }
nu-parser = { path = "../nu-parser", version = "0.95.0" }
nu-protocol = { path = "../nu-protocol", version = "0.95.0" }
reedline = { workspace = true }
@ -23,8 +23,8 @@ serde = { workspace = true }
serde_json = { workspace = true }
[dev-dependencies]
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.94.3" }
nu-command = { path = "../nu-command", version = "0.94.3" }
nu-test-support = { path = "../nu-test-support", version = "0.94.3" }
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.95.0" }
nu-command = { path = "../nu-command", version = "0.95.0" }
nu-test-support = { path = "../nu-test-support", version = "0.95.0" }
assert-json-diff = "2.0"
assert-json-diff = "2.0"

View File

@ -5,17 +5,17 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-parser"
edition = "2021"
license = "MIT"
name = "nu-parser"
version = "0.94.3"
version = "0.95.0"
exclude = ["/fuzz"]
[lib]
bench = false
[dependencies]
nu-engine = { path = "../nu-engine", version = "0.94.3" }
nu-path = { path = "../nu-path", version = "0.94.3" }
nu-plugin-engine = { path = "../nu-plugin-engine", optional = true, version = "0.94.3" }
nu-protocol = { path = "../nu-protocol", version = "0.94.3" }
nu-engine = { path = "../nu-engine", version = "0.95.0" }
nu-path = { path = "../nu-path", version = "0.95.0" }
nu-plugin-engine = { path = "../nu-plugin-engine", optional = true, version = "0.95.0" }
nu-protocol = { path = "../nu-protocol", version = "0.95.0" }
bytesize = { workspace = true }
chrono = { default-features = false, features = ['std'], workspace = true }
@ -27,4 +27,4 @@ serde_json = { workspace = true }
rstest = { workspace = true, default-features = false }
[features]
plugin = ["nu-plugin-engine"]
plugin = ["nu-plugin-engine"]

View File

@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-path"
edition = "2021"
license = "MIT"
name = "nu-path"
version = "0.94.3"
version = "0.95.0"
exclude = ["/fuzz"]
[lib]
@ -18,4 +18,4 @@ dirs-next = { workspace = true }
omnipath = { workspace = true }
[target.'cfg(all(unix, not(target_os = "macos"), not(target_os = "android")))'.dependencies]
pwd = { workspace = true }
pwd = { workspace = true }

View File

@ -5,14 +5,14 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-plugin-core
edition = "2021"
license = "MIT"
name = "nu-plugin-core"
version = "0.94.3"
version = "0.95.0"
[lib]
bench = false
[dependencies]
nu-protocol = { path = "../nu-protocol", version = "0.94.3" }
nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.94.3", default-features = false }
nu-protocol = { path = "../nu-protocol", version = "0.95.0" }
nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.95.0", default-features = false }
rmp-serde = { workspace = true }
serde = { workspace = true }
@ -25,4 +25,4 @@ default = ["local-socket"]
local-socket = ["interprocess", "nu-plugin-protocol/local-socket"]
[target.'cfg(target_os = "windows")'.dependencies]
windows = { workspace = true }
windows = { workspace = true }

View File

@ -5,17 +5,17 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-plugin-engi
edition = "2021"
license = "MIT"
name = "nu-plugin-engine"
version = "0.94.3"
version = "0.95.0"
[lib]
bench = false
[dependencies]
nu-engine = { path = "../nu-engine", version = "0.94.3" }
nu-protocol = { path = "../nu-protocol", version = "0.94.3" }
nu-system = { path = "../nu-system", version = "0.94.3" }
nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.94.3" }
nu-plugin-core = { path = "../nu-plugin-core", version = "0.94.3", default-features = false }
nu-engine = { path = "../nu-engine", version = "0.95.0" }
nu-protocol = { path = "../nu-protocol", version = "0.95.0" }
nu-system = { path = "../nu-system", version = "0.95.0" }
nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.95.0" }
nu-plugin-core = { path = "../nu-plugin-core", version = "0.95.0", default-features = false }
serde = { workspace = true }
log = { workspace = true }
@ -31,4 +31,4 @@ local-socket = ["nu-plugin-core/local-socket"]
windows = { workspace = true, features = [
# For setting process creation flags
"Win32_System_Threading",
] }
] }

View File

@ -5,14 +5,14 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-plugin-prot
edition = "2021"
license = "MIT"
name = "nu-plugin-protocol"
version = "0.94.3"
version = "0.95.0"
[lib]
bench = false
[dependencies]
nu-protocol = { path = "../nu-protocol", version = "0.94.3", features = ["plugin"] }
nu-utils = { path = "../nu-utils", version = "0.94.3" }
nu-protocol = { path = "../nu-protocol", version = "0.95.0", features = ["plugin"] }
nu-utils = { path = "../nu-utils", version = "0.95.0" }
bincode = "1.3"
serde = { workspace = true, features = ["derive"] }
@ -21,4 +21,4 @@ typetag = "0.2"
[features]
default = ["local-socket"]
local-socket = []
local-socket = []

View File

@ -1,6 +1,6 @@
[package]
name = "nu-plugin-test-support"
version = "0.94.3"
version = "0.95.0"
edition = "2021"
license = "MIT"
description = "Testing support for Nushell plugins"
@ -12,17 +12,17 @@ bench = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
nu-engine = { path = "../nu-engine", version = "0.94.3", features = ["plugin"] }
nu-protocol = { path = "../nu-protocol", version = "0.94.3", features = ["plugin"] }
nu-parser = { path = "../nu-parser", version = "0.94.3", features = ["plugin"] }
nu-plugin = { path = "../nu-plugin", version = "0.94.3" }
nu-plugin-core = { path = "../nu-plugin-core", version = "0.94.3" }
nu-plugin-engine = { path = "../nu-plugin-engine", version = "0.94.3" }
nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.94.3" }
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.94.3" }
nu-engine = { path = "../nu-engine", version = "0.95.0", features = ["plugin"] }
nu-protocol = { path = "../nu-protocol", version = "0.95.0", features = ["plugin"] }
nu-parser = { path = "../nu-parser", version = "0.95.0", features = ["plugin"] }
nu-plugin = { path = "../nu-plugin", version = "0.95.0" }
nu-plugin-core = { path = "../nu-plugin-core", version = "0.95.0" }
nu-plugin-engine = { path = "../nu-plugin-engine", version = "0.95.0" }
nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.95.0" }
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.95.0" }
nu-ansi-term = { workspace = true }
similar = "2.5"
[dev-dependencies]
typetag = "0.2"
serde = "1.0"
serde = "1.0"

View File

@ -5,16 +5,16 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-plugin"
edition = "2021"
license = "MIT"
name = "nu-plugin"
version = "0.94.3"
version = "0.95.0"
[lib]
bench = false
[dependencies]
nu-engine = { path = "../nu-engine", version = "0.94.3" }
nu-protocol = { path = "../nu-protocol", version = "0.94.3" }
nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.94.3" }
nu-plugin-core = { path = "../nu-plugin-core", version = "0.94.3", default-features = false }
nu-engine = { path = "../nu-engine", version = "0.95.0" }
nu-protocol = { path = "../nu-protocol", version = "0.95.0" }
nu-plugin-protocol = { path = "../nu-plugin-protocol", version = "0.95.0" }
nu-plugin-core = { path = "../nu-plugin-core", version = "0.95.0", default-features = false }
log = { workspace = true }
thiserror = "1.0"
@ -29,4 +29,4 @@ local-socket = ["nu-plugin-core/local-socket"]
[target.'cfg(target_family = "unix")'.dependencies]
# For setting the process group ID (EnterForeground / LeaveForeground)
nix = { workspace = true, default-features = false, features = ["process"] }
nix = { workspace = true, default-features = false, features = ["process"] }

View File

@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-pretty-hex"
edition = "2021"
license = "MIT"
name = "nu-pretty-hex"
version = "0.94.3"
version = "0.95.0"
[lib]
doctest = false
@ -18,4 +18,4 @@ nu-ansi-term = { workspace = true }
[dev-dependencies]
heapless = { version = "0.8", default-features = false }
rand = "0.8"
rand = "0.8"

View File

@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-protocol"
edition = "2021"
license = "MIT"
name = "nu-protocol"
version = "0.94.3"
version = "0.95.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -13,10 +13,10 @@ version = "0.94.3"
bench = false
[dependencies]
nu-utils = { path = "../nu-utils", version = "0.94.3" }
nu-path = { path = "../nu-path", version = "0.94.3" }
nu-system = { path = "../nu-system", version = "0.94.3" }
nu-derive-value = { path = "../nu-derive-value", version = "0.94.3" }
nu-utils = { path = "../nu-utils", version = "0.95.0" }
nu-path = { path = "../nu-path", version = "0.95.0" }
nu-system = { path = "../nu-system", version = "0.95.0" }
nu-derive-value = { path = "../nu-derive-value", version = "0.95.0" }
brotli = { workspace = true, optional = true }
byte-unit = { version = "5.1", features = [ "serde" ] }
@ -47,11 +47,11 @@ plugin = [
serde_json = { workspace = true }
strum = "0.26"
strum_macros = "0.26"
nu-test-support = { path = "../nu-test-support", version = "0.94.3" }
nu-test-support = { path = "../nu-test-support", version = "0.95.0" }
pretty_assertions = { workspace = true }
rstest = { workspace = true }
tempfile = { workspace = true }
os_pipe = { workspace = true }
[package.metadata.docs.rs]
all-features = true
all-features = true

View File

@ -81,7 +81,9 @@ pub(super) fn build_usage(comment_lines: &[&[u8]]) -> (String, String) {
usage.push_str(&comment_line);
}
if let Some((brief_usage, extra_usage)) = usage.split_once("\n\n") {
if let Some((brief_usage, extra_usage)) = usage.split_once("\r\n\r\n") {
(brief_usage.to_string(), extra_usage.to_string())
} else if let Some((brief_usage, extra_usage)) = usage.split_once("\n\n") {
(brief_usage.to_string(), extra_usage.to_string())
} else {
(usage, String::default())

View File

@ -171,6 +171,62 @@ fn named_fields_struct_incorrect_type() {
assert!(res.is_err());
}
#[derive(IntoValue, FromValue, Debug, PartialEq, Default)]
struct ALotOfOptions {
required: bool,
float: Option<f64>,
int: Option<i64>,
value: Option<Value>,
nested: Option<Nestee>,
}
#[test]
fn missing_options() {
let value = Value::test_record(Record::new());
let res: Result<ALotOfOptions, _> = ALotOfOptions::from_value(value);
assert!(res.is_err());
let value = Value::test_record(record! {"required" => Value::test_bool(true)});
let expected = ALotOfOptions {
required: true,
..Default::default()
};
let actual = ALotOfOptions::from_value(value).unwrap();
assert_eq!(expected, actual);
let value = Value::test_record(record! {
"required" => Value::test_bool(true),
"float" => Value::test_float(std::f64::consts::PI),
});
let expected = ALotOfOptions {
required: true,
float: Some(std::f64::consts::PI),
..Default::default()
};
let actual = ALotOfOptions::from_value(value).unwrap();
assert_eq!(expected, actual);
let value = Value::test_record(record! {
"required" => Value::test_bool(true),
"int" => Value::test_int(12),
"nested" => Value::test_record(record! {
"u32" => Value::test_int(34),
}),
});
let expected = ALotOfOptions {
required: true,
int: Some(12),
nested: Some(Nestee {
u32: 34,
some: None,
none: None,
}),
..Default::default()
};
let actual = ALotOfOptions::from_value(value).unwrap();
assert_eq!(expected, actual);
}
#[derive(IntoValue, FromValue, Debug, PartialEq)]
struct UnnamedFieldsStruct<T>(u32, String, T)
where

View File

@ -5,12 +5,12 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-std"
edition = "2021"
license = "MIT"
name = "nu-std"
version = "0.94.3"
version = "0.95.0"
[dependencies]
nu-parser = { version = "0.94.3", path = "../nu-parser" }
nu-protocol = { version = "0.94.3", path = "../nu-protocol" }
nu-engine = { version = "0.94.3", path = "../nu-engine" }
nu-parser = { version = "0.95.0", path = "../nu-parser" }
nu-protocol = { version = "0.95.0", path = "../nu-protocol" }
nu-engine = { version = "0.95.0", path = "../nu-engine" }
miette = { workspace = true, features = ["fancy-no-backtrace"] }
log = "0.4"
log = "0.4"

View File

@ -3,7 +3,7 @@ authors = ["The Nushell Project Developers", "procs creators"]
description = "Nushell system querying"
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-system"
name = "nu-system"
version = "0.94.3"
version = "0.95.0"
edition = "2021"
license = "MIT"
@ -45,4 +45,4 @@ windows = { workspace = true, features = [
"Win32_System_SystemInformation",
"Win32_System_Threading",
"Win32_UI_Shell",
]}
]}

View File

@ -5,20 +5,20 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-table"
edition = "2021"
license = "MIT"
name = "nu-table"
version = "0.94.3"
version = "0.95.0"
[lib]
bench = false
[dependencies]
nu-protocol = { path = "../nu-protocol", version = "0.94.3" }
nu-utils = { path = "../nu-utils", version = "0.94.3" }
nu-engine = { path = "../nu-engine", version = "0.94.3" }
nu-color-config = { path = "../nu-color-config", version = "0.94.3" }
nu-protocol = { path = "../nu-protocol", version = "0.95.0" }
nu-utils = { path = "../nu-utils", version = "0.95.0" }
nu-engine = { path = "../nu-engine", version = "0.95.0" }
nu-color-config = { path = "../nu-color-config", version = "0.95.0" }
nu-ansi-term = { workspace = true }
once_cell = { workspace = true }
fancy-regex = { workspace = true }
tabled = { workspace = true, features = ["color"], default-features = false }
[dev-dependencies]
# nu-test-support = { path="../nu-test-support", version = "0.94.3" }
# nu-test-support = { path="../nu-test-support", version = "0.95.0" }

View File

@ -5,12 +5,12 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-term-grid"
edition = "2021"
license = "MIT"
name = "nu-term-grid"
version = "0.94.3"
version = "0.95.0"
[lib]
bench = false
[dependencies]
nu-utils = { path = "../nu-utils", version = "0.94.3" }
nu-utils = { path = "../nu-utils", version = "0.95.0" }
unicode-width = { workspace = true }
unicode-width = { workspace = true }

View File

@ -5,17 +5,17 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu-test-suppor
edition = "2021"
license = "MIT"
name = "nu-test-support"
version = "0.94.3"
version = "0.95.0"
[lib]
doctest = false
bench = false
[dependencies]
nu-path = { path = "../nu-path", version = "0.94.3" }
nu-glob = { path = "../nu-glob", version = "0.94.3" }
nu-utils = { path = "../nu-utils", version = "0.94.3" }
nu-path = { path = "../nu-path", version = "0.95.0" }
nu-glob = { path = "../nu-glob", version = "0.95.0" }
nu-utils = { path = "../nu-utils", version = "0.95.0" }
num-format = { workspace = true }
which = { workspace = true }
tempfile = { workspace = true }
tempfile = { workspace = true }

View File

@ -5,7 +5,7 @@ edition = "2021"
license = "MIT"
name = "nu-utils"
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-utils"
version = "0.94.3"
version = "0.95.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[[bin]]
@ -29,4 +29,4 @@ unicase = "2.7.0"
crossterm_winapi = "0.9"
[target.'cfg(unix)'.dependencies]
nix = { workspace = true, default-features = false, features = ["user", "fs"] }
nix = { workspace = true, default-features = false, features = ["user", "fs"] }

View File

@ -1,6 +1,6 @@
# Nushell Config File
#
# version = "0.94.3"
# version = "0.95.0"
# For more information on defining custom themes, see
# https://www.nushell.sh/book/coloring_and_theming.html
@ -888,4 +888,4 @@ $env.config = {
event: { edit: selectall }
}
]
}
}

View File

@ -1,6 +1,6 @@
# Nushell Environment Config File
#
# version = "0.94.3"
# version = "0.95.0"
def create_left_prompt [] {
let dir = match (do --ignore-shell-errors { $env.PWD | path relative-to $nu.home-path }) {
@ -98,4 +98,4 @@ $env.NU_PLUGIN_DIRS = [
# $env.PATH = ($env.PATH | uniq)
# To load from a custom file you can use:
# source ($nu.default-config-dir | path join 'custom.nu')
# source ($nu.default-config-dir | path join 'custom.nu')

View File

@ -10,10 +10,10 @@ name = "nu_plugin_custom_values"
bench = false
[dependencies]
nu-plugin = { path = "../nu-plugin", version = "0.94.3" }
nu-protocol = { path = "../nu-protocol", version = "0.94.3", features = ["plugin"] }
nu-plugin = { path = "../nu-plugin", version = "0.95.0" }
nu-protocol = { path = "../nu-protocol", version = "0.95.0", features = ["plugin"] }
serde = { workspace = true, default-features = false }
typetag = "0.2"
[dev-dependencies]
nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.94.3" }
nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.95.0" }

View File

@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu_plugin_exam
edition = "2021"
license = "MIT"
name = "nu_plugin_example"
version = "0.94.3"
version = "0.95.0"
[[bin]]
name = "nu_plugin_example"
@ -15,9 +15,9 @@ bench = false
bench = false
[dependencies]
nu-plugin = { path = "../nu-plugin", version = "0.94.3" }
nu-protocol = { path = "../nu-protocol", version = "0.94.3", features = ["plugin"] }
nu-plugin = { path = "../nu-plugin", version = "0.95.0" }
nu-protocol = { path = "../nu-protocol", version = "0.95.0", features = ["plugin"] }
[dev-dependencies]
nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.94.3" }
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.94.3" }
nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.95.0" }
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.95.0" }

View File

@ -5,12 +5,12 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu_plugin_form
edition = "2021"
license = "MIT"
name = "nu_plugin_formats"
version = "0.94.3"
version = "0.95.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
nu-plugin = { path = "../nu-plugin", version = "0.94.3" }
nu-protocol = { path = "../nu-protocol", version = "0.94.3", features = ["plugin"] }
nu-plugin = { path = "../nu-plugin", version = "0.95.0" }
nu-protocol = { path = "../nu-protocol", version = "0.95.0", features = ["plugin"] }
indexmap = { workspace = true }
eml-parser = "0.1"
@ -18,4 +18,4 @@ ical = "0.11"
rust-ini = "0.21.0"
[dev-dependencies]
nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.94.3" }
nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.95.0" }

View File

@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu_plugin_gsta
edition = "2021"
license = "MIT"
name = "nu_plugin_gstat"
version = "0.94.3"
version = "0.95.0"
[lib]
doctest = false
@ -16,7 +16,7 @@ name = "nu_plugin_gstat"
bench = false
[dependencies]
nu-plugin = { path = "../nu-plugin", version = "0.94.3" }
nu-protocol = { path = "../nu-protocol", version = "0.94.3" }
nu-plugin = { path = "../nu-plugin", version = "0.95.0" }
nu-protocol = { path = "../nu-protocol", version = "0.95.0" }
git2 = "0.19"
git2 = "0.19"

View File

@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu_plugin_inc"
edition = "2021"
license = "MIT"
name = "nu_plugin_inc"
version = "0.94.3"
version = "0.95.0"
[lib]
doctest = false
@ -16,7 +16,7 @@ name = "nu_plugin_inc"
bench = false
[dependencies]
nu-plugin = { path = "../nu-plugin", version = "0.94.3" }
nu-protocol = { path = "../nu-protocol", version = "0.94.3", features = ["plugin"] }
nu-plugin = { path = "../nu-plugin", version = "0.95.0" }
nu-protocol = { path = "../nu-protocol", version = "0.95.0", features = ["plugin"] }
semver = "1.0"
semver = "1.0"

View File

@ -6,7 +6,7 @@
# it also allows us to test the plugin interface with something manually implemented in a scripting
# language without adding any extra dependencies to our tests.
const NUSHELL_VERSION = "0.94.3"
const NUSHELL_VERSION = "0.95.0"
const PLUGIN_VERSION = "0.1.0" # bump if you change commands!
def main [--stdio] {
@ -265,4 +265,4 @@ def start_plugin [] {
}) |
each { from json | handle_input } |
ignore
}
}

View File

@ -5,7 +5,7 @@ edition = "2021"
license = "MIT"
name = "nu_plugin_polars"
repository = "https://github.com/nushell/nushell/tree/main/crates/nu_plugin_polars"
version = "0.94.3"
version = "0.95.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -17,10 +17,10 @@ bench = false
bench = false
[dependencies]
nu-protocol = { path = "../nu-protocol", version = "0.94.3" }
nu-plugin = { path = "../nu-plugin", version = "0.94.3" }
nu-path = { path = "../nu-path", version = "0.94.3" }
nu-utils = { path = "../nu-utils", version = "0.94.3" }
nu-protocol = { path = "../nu-protocol", version = "0.95.0" }
nu-plugin = { path = "../nu-plugin", version = "0.95.0" }
nu-path = { path = "../nu-path", version = "0.95.0" }
nu-utils = { path = "../nu-utils", version = "0.95.0" }
# Potential dependencies for extras
chrono = { workspace = true, features = ["std", "unstable-locales"], default-features = false }
@ -76,9 +76,9 @@ optional = false
version = "0.40"
[dev-dependencies]
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.94.3" }
nu-engine = { path = "../nu-engine", version = "0.94.3" }
nu-parser = { path = "../nu-parser", version = "0.94.3" }
nu-command = { path = "../nu-command", version = "0.94.3" }
nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.94.3" }
nu-cmd-lang = { path = "../nu-cmd-lang", version = "0.95.0" }
nu-engine = { path = "../nu-engine", version = "0.95.0" }
nu-parser = { path = "../nu-parser", version = "0.95.0" }
nu-command = { path = "../nu-command", version = "0.95.0" }
nu-plugin-test-support = { path = "../nu-plugin-test-support", version = "0.95.0" }
tempfile.workspace = true

View File

@ -32,6 +32,8 @@ use polars_io::{
avro::AvroReader, csv::read::CsvReadOptions, prelude::ParallelStrategy, HiveOptions,
};
const DEFAULT_INFER_SCHEMA: usize = 100;
#[derive(Clone)]
pub struct OpenDataFrame;
@ -374,7 +376,9 @@ fn from_jsonl(
file_path: &Path,
file_span: Span,
) -> Result<Value, ShellError> {
let infer_schema: Option<usize> = call.get_flag("infer-schema")?;
let infer_schema: usize = call
.get_flag("infer-schema")?
.unwrap_or(DEFAULT_INFER_SCHEMA);
let maybe_schema = call
.get_flag("schema")?
.map(|schema| NuSchema::try_from(&schema))
@ -384,7 +388,7 @@ fn from_jsonl(
let start_time = std::time::Instant::now();
let df = LazyJsonLineReader::new(file_path)
.with_infer_schema_length(infer_schema)
.with_infer_schema_length(Some(infer_schema))
.with_schema(maybe_schema.map(|s| s.into()))
.finish()
.map_err(|e| ShellError::GenericError {
@ -414,7 +418,7 @@ fn from_jsonl(
let buf_reader = BufReader::new(file);
let reader = JsonReader::new(buf_reader)
.with_json_format(JsonFormat::JsonLines)
.infer_schema_len(infer_schema);
.infer_schema_len(Some(infer_schema));
let reader = match maybe_schema {
Some(schema) => reader.with_schema(schema.into()),
@ -453,7 +457,9 @@ fn from_csv(
) -> Result<Value, ShellError> {
let delimiter: Option<Spanned<String>> = call.get_flag("delimiter")?;
let no_header: bool = call.has_flag("no-header")?;
let infer_schema: Option<usize> = call.get_flag("infer-schema")?;
let infer_schema: usize = call
.get_flag("infer-schema")?
.unwrap_or(DEFAULT_INFER_SCHEMA);
let skip_rows: Option<usize> = call.get_flag("skip-rows")?;
let columns: Option<Vec<String>> = call.get_flag("columns")?;
@ -493,10 +499,7 @@ fn from_csv(
None => csv_reader,
};
let csv_reader = match infer_schema {
None => csv_reader,
Some(r) => csv_reader.with_infer_schema_length(Some(r)),
};
let csv_reader = csv_reader.with_infer_schema_length(Some(infer_schema));
let csv_reader = match skip_rows {
None => csv_reader,
@ -522,7 +525,7 @@ fn from_csv(
let start_time = std::time::Instant::now();
let df = CsvReadOptions::default()
.with_has_header(!no_header)
.with_infer_schema_length(infer_schema)
.with_infer_schema_length(Some(infer_schema))
.with_skip_rows(skip_rows.unwrap_or_default())
.with_schema(maybe_schema.map(|s| s.into()))
.with_columns(columns.map(Arc::new))

View File

@ -27,7 +27,7 @@ import sys
import json
NUSHELL_VERSION = "0.94.3"
NUSHELL_VERSION = "0.95.0"
PLUGIN_VERSION = "0.1.0" # bump if you change commands!
@ -258,4 +258,4 @@ if __name__ == "__main__":
if len(sys.argv) == 2 and sys.argv[1] == "--stdio":
plugin()
else:
print("Run me from inside nushell!")
print("Run me from inside nushell!")

View File

@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu_plugin_quer
edition = "2021"
license = "MIT"
name = "nu_plugin_query"
version = "0.94.3"
version = "0.95.0"
[lib]
doctest = false
@ -16,10 +16,10 @@ name = "nu_plugin_query"
bench = false
[dependencies]
nu-plugin = { path = "../nu-plugin", version = "0.94.3" }
nu-protocol = { path = "../nu-protocol", version = "0.94.3" }
nu-plugin = { path = "../nu-plugin", version = "0.95.0" }
nu-protocol = { path = "../nu-protocol", version = "0.95.0" }
gjson = "0.8"
scraper = { default-features = false, version = "0.19" }
sxd-document = "0.3"
sxd-xpath = "0.4"
sxd-xpath = "0.4"

View File

@ -5,7 +5,7 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nu_plugin_stre
edition = "2021"
license = "MIT"
name = "nu_plugin_stress_internals"
version = "0.94.3"
version = "0.95.0"
[[bin]]
name = "nu_plugin_stress_internals"
@ -16,4 +16,4 @@ bench = false
# assumptions about the serialized format
serde = { workspace = true }
serde_json = { workspace = true }
interprocess = { workspace = true }
interprocess = { workspace = true }

View File

@ -5,16 +5,16 @@ repository = "https://github.com/nushell/nushell/tree/main/crates/nuon"
edition = "2021"
license = "MIT"
name = "nuon"
version = "0.94.3"
version = "0.95.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
nu-parser = { path = "../nu-parser", version = "0.94.3" }
nu-protocol = { path = "../nu-protocol", version = "0.94.3" }
nu-engine = { path = "../nu-engine", version = "0.94.3" }
nu-parser = { path = "../nu-parser", version = "0.95.0" }
nu-protocol = { path = "../nu-protocol", version = "0.95.0" }
nu-engine = { path = "../nu-engine", version = "0.95.0" }
once_cell = { workspace = true }
fancy-regex = { workspace = true }
[dev-dependencies]
chrono = { workspace = true }
chrono = { workspace = true }

View File

@ -261,6 +261,22 @@ fn commands_have_usage() -> TestResult {
)
}
#[test]
fn commands_from_crlf_source_have_short_usage() -> TestResult {
run_test_contains(
"# This is a test\r\n#\r\n# To see if I have cool usage\r\ndef foo [] {}\r\nscope commands | where name == foo | get usage.0",
"This is a test",
)
}
#[test]
fn commands_from_crlf_source_have_extra_usage() -> TestResult {
run_test_contains(
"# This is a test\r\n#\r\n# To see if I have cool usage\r\ndef foo [] {}\r\nscope commands | where name == foo | get extra_usage.0",
"To see if I have cool usage",
)
}
#[test]
fn equals_separates_long_flag() -> TestResult {
run_test(