diff --git a/.github/workflows/check_flake.yml b/.github/workflows/check_flake.yml
index d80ffff..fb44aab 100644
--- a/.github/workflows/check_flake.yml
+++ b/.github/workflows/check_flake.yml
@@ -1,4 +1,4 @@
-name: Check Nix flake
+name: Nix
on:
pull_request:
push:
@@ -7,7 +7,8 @@ on:
- 'flake.nix'
jobs:
- check:
+ check_flake:
+ name: Check Flake
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
diff --git a/.github/workflows/pull_request.yml b/.github/workflows/check_rust.yaml
similarity index 94%
rename from .github/workflows/pull_request.yml
rename to .github/workflows/check_rust.yaml
index e069216..39577ef 100644
--- a/.github/workflows/pull_request.yml
+++ b/.github/workflows/check_rust.yaml
@@ -1,6 +1,10 @@
-# Jobs on pull request
-name: Pull request
-on: pull_request
+name: Rust
+on:
+ workflow_dispatch:
+ push:
+ branches:
+ - main
+ pull_request:
jobs:
format:
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
deleted file mode 100644
index 9ccb8a8..0000000
--- a/.github/workflows/main.yml
+++ /dev/null
@@ -1,62 +0,0 @@
-# This workflow run when something is pushed on main and it does
-# normal checks like in the normal PRs
-
-# Jobs on pull request
-name: CI on main
-on:
- workflow_dispatch:
- push:
- branches:
- - main
-
-jobs:
- format:
- name: format rust files
- runs-on: ubuntu-latest
- steps:
- - name: checkout repository
- uses: actions/checkout@v3
- - name: Setup Rust toolchain and cache
- uses: actions-rust-lang/setup-rust-toolchain@v1.4.4
- - name: format files
- run: cargo fmt --all --check
-
- lint:
- name: lint all rust files
- runs-on: ubuntu-latest
- steps:
- - name: checkout repository
- uses: actions/checkout@v3
- - name: Setup Rust toolchain and cache
- uses: actions-rust-lang/setup-rust-toolchain@v1.4.4
- - name: Clippy
- run: |
- cargo clippy \
- --all-targets \
- --no-deps \
- --workspace \
- -- \
- -D warnings \
- -D rustdoc::broken_intra_doc_links \
- -W clippy::explicit_iter_loop \
- -W clippy::explicit_into_iter_loop \
- -W clippy::semicolon_if_nothing_returned \
- -W clippy::doc_markdown \
- -W clippy::manual_let_else
-
- test:
- name: test rust files
- strategy:
- matrix:
- include:
- - os: windows-latest
- - os: ubuntu-latest
-
- runs-on: ${{ matrix.os }}
- steps:
- - name: checkout repository
- uses: actions/checkout@v3
- - name: Setup Rust toolchain and cache
- uses: actions-rust-lang/setup-rust-toolchain@v1.4.4
- - name: run tests
- run: cargo test --workspace
diff --git a/docs/CONTRIBUTING.md b/CONTRIBUTING.md
similarity index 100%
rename from docs/CONTRIBUTING.md
rename to CONTRIBUTING.md
diff --git a/Cargo.lock b/Cargo.lock
index 99b2492..2480e2d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2,17 +2,6 @@
# It is not intended for manual editing.
version = 3
-[[package]]
-name = "ahash"
-version = "0.7.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
-dependencies = [
- "getrandom",
- "once_cell",
- "version_check",
-]
-
[[package]]
name = "ahash"
version = "0.8.3"
@@ -26,9 +15,9 @@ dependencies = [
[[package]]
name = "aho-corasick"
-version = "1.0.1"
+version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04"
+checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab"
dependencies = [
"memchr",
]
@@ -48,38 +37,31 @@ dependencies = [
"libc",
]
-[[package]]
-name = "anes"
-version = "0.1.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
-
[[package]]
name = "anstream"
-version = "0.3.2"
+version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163"
+checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
- "is-terminal",
"utf8parse",
]
[[package]]
name = "anstyle"
-version = "1.0.0"
+version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d"
+checksum = "b84bf0a05bbb2a83e5eb6fa36bb6e87baa08193c35ff52bbf6b38d8af2890e46"
[[package]]
name = "anstyle-parse"
-version = "0.2.0"
+version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee"
+checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333"
dependencies = [
"utf8parse",
]
@@ -95,20 +77,14 @@ dependencies = [
[[package]]
name = "anstyle-wincon"
-version = "1.0.1"
+version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188"
+checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd"
dependencies = [
"anstyle",
"windows-sys 0.48.0",
]
-[[package]]
-name = "anyhow"
-version = "1.0.71"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8"
-
[[package]]
name = "arrayvec"
version = "0.5.2"
@@ -117,9 +93,9 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]]
name = "arrayvec"
-version = "0.7.2"
+version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6"
+checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
[[package]]
name = "autocfg"
@@ -148,11 +124,17 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
+[[package]]
+name = "bitflags"
+version = "2.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
+
[[package]]
name = "bumpalo"
-version = "3.13.0"
+version = "3.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1"
+checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec"
[[package]]
name = "byte-unit"
@@ -166,21 +148,18 @@ dependencies = [
[[package]]
name = "bytesize"
-version = "1.2.0"
+version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "38fcc2979eff34a4b84e1cf9a1e3da42a7d44b3b690a40cdcb23e3d556cfb2e5"
-
-[[package]]
-name = "cast"
-version = "0.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
+checksum = "a3e368af43e418a04d52505cf3dbc23dda4e3407ae2fa99fd0e4f308ce546acc"
[[package]]
name = "cc"
-version = "1.0.79"
+version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
+checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
+dependencies = [
+ "libc",
+]
[[package]]
name = "cfg-if"
@@ -190,76 +169,44 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
-version = "0.4.26"
+version = "0.4.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5"
+checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38"
dependencies = [
"android-tzdata",
"iana-time-zone",
- "js-sys",
"num-traits",
"serde",
- "time",
- "wasm-bindgen",
- "winapi",
+ "windows-targets 0.48.5",
]
[[package]]
name = "chrono-humanize"
-version = "0.2.2"
+version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "32dce1ea1988dbdf9f9815ff11425828523bd2a134ec0805d2ac8af26ee6096e"
+checksum = "799627e6b4d27827a814e837b9d8a504832086081806d45b1afa34dc982b023b"
dependencies = [
"chrono",
]
-[[package]]
-name = "ciborium"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926"
-dependencies = [
- "ciborium-io",
- "ciborium-ll",
- "serde",
-]
-
-[[package]]
-name = "ciborium-io"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656"
-
-[[package]]
-name = "ciborium-ll"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b"
-dependencies = [
- "ciborium-io",
- "half",
-]
-
[[package]]
name = "clap"
-version = "4.3.0"
+version = "4.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "93aae7a4192245f70fe75dd9157fc7b4a5bf53e88d30bd4396f7d8f9284d5acc"
+checksum = "824956d0dca8334758a5b7f7e50518d66ea319330cbceedcf76905c2f6ab30e3"
dependencies = [
"clap_builder",
"clap_derive",
- "once_cell",
]
[[package]]
name = "clap_builder"
-version = "4.3.0"
+version = "4.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4f423e341edefb78c9caba2d9c7f7687d0e72e89df3ce3394554754393ac3990"
+checksum = "122ec64120a49b4563ccaedcbea7818d069ed8e9aa6d829b82d8a4128936b2ab"
dependencies = [
"anstream",
"anstyle",
- "bitflags",
"clap_lex",
"strsim",
"unicase",
@@ -268,21 +215,21 @@ dependencies = [
[[package]]
name = "clap_derive"
-version = "4.3.0"
+version = "4.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "191d9573962933b4027f932c600cd252ce27a8ad5979418fe78e43c07996f27b"
+checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873"
dependencies = [
"heck",
"proc-macro2",
"quote",
- "syn 2.0.18",
+ "syn 2.0.37",
]
[[package]]
name = "clap_lex"
-version = "0.5.0"
+version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b"
+checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961"
[[package]]
name = "colorchoice"
@@ -296,52 +243,6 @@ version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa"
-[[package]]
-name = "criterion"
-version = "0.5.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f"
-dependencies = [
- "anes",
- "cast",
- "ciborium",
- "clap",
- "criterion-plot",
- "is-terminal",
- "itertools",
- "num-traits",
- "once_cell",
- "oorandom",
- "plotters",
- "rayon",
- "regex",
- "serde",
- "serde_derive",
- "serde_json",
- "tinytemplate",
- "walkdir",
-]
-
-[[package]]
-name = "criterion-plot"
-version = "0.5.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1"
-dependencies = [
- "cast",
- "itertools",
-]
-
-[[package]]
-name = "crossbeam-channel"
-version = "0.5.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200"
-dependencies = [
- "cfg-if",
- "crossbeam-utils",
-]
-
[[package]]
name = "crossbeam-deque"
version = "0.8.3"
@@ -355,9 +256,9 @@ dependencies = [
[[package]]
name = "crossbeam-epoch"
-version = "0.9.14"
+version = "0.9.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695"
+checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7"
dependencies = [
"autocfg",
"cfg-if",
@@ -368,18 +269,18 @@ dependencies = [
[[package]]
name = "crossbeam-utils"
-version = "0.8.15"
+version = "0.8.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b"
+checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294"
dependencies = [
"cfg-if",
]
[[package]]
name = "crossterm_winapi"
-version = "0.9.0"
+version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2ae1b35a484aa10e07fe0638d02301c5ad24de82d310ccbd2f3693da5f09bf1c"
+checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b"
dependencies = [
"winapi",
]
@@ -407,9 +308,9 @@ dependencies = [
[[package]]
name = "either"
-version = "1.8.1"
+version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
+checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]]
name = "env_logger"
@@ -426,18 +327,18 @@ dependencies = [
[[package]]
name = "erased-serde"
-version = "0.3.25"
+version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4f2b0c2380453a92ea8b6c8e5f64ecaafccddde8ceab55ff7a8ac1029f894569"
+checksum = "6c138974f9d5e7fe373eb04df7cae98833802ae4b11c24ac7039a21d5af4b26c"
dependencies = [
"serde",
]
[[package]]
name = "errno"
-version = "0.3.1"
+version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a"
+checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd"
dependencies = [
"errno-dragonfly",
"libc",
@@ -466,40 +367,20 @@ dependencies = [
[[package]]
name = "getrandom"
-version = "0.2.9"
+version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4"
+checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427"
dependencies = [
"cfg-if",
"libc",
- "wasi 0.11.0+wasi-snapshot-preview1",
-]
-
-[[package]]
-name = "ghost"
-version = "0.1.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e77ac7b51b8e6313251737fcef4b1c01a2ea102bde68415b62c0ee9268fec357"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn 2.0.18",
+ "wasi",
]
-[[package]]
-name = "half"
-version = "1.8.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
-
[[package]]
name = "hashbrown"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
-dependencies = [
- "ahash 0.7.6",
-]
[[package]]
name = "hashbrown"
@@ -507,7 +388,7 @@ version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
dependencies = [
- "ahash 0.8.3",
+ "ahash",
]
[[package]]
@@ -518,18 +399,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "hermit-abi"
-version = "0.2.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7"
-dependencies = [
- "libc",
-]
-
-[[package]]
-name = "hermit-abi"
-version = "0.3.1"
+version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
+checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"
[[package]]
name = "humantime"
@@ -539,9 +411,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "iana-time-zone"
-version = "0.1.56"
+version = "0.1.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c"
+checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613"
dependencies = [
"android_system_properties",
"core-foundation-sys",
@@ -572,32 +444,17 @@ dependencies = [
[[package]]
name = "inventory"
-version = "0.3.6"
+version = "0.3.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e0539b5de9241582ce6bd6b0ba7399313560151e58c9aaf8b74b711b1bdce644"
-dependencies = [
- "ghost",
-]
-
-[[package]]
-name = "io-lifetimes"
-version = "1.0.11"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2"
-dependencies = [
- "hermit-abi 0.3.1",
- "libc",
- "windows-sys 0.48.0",
-]
+checksum = "e1be380c410bf0595e94992a648ea89db4dd3f3354ba54af206fd2a68cf5ac8e"
[[package]]
name = "is-terminal"
-version = "0.4.7"
+version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f"
+checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
dependencies = [
- "hermit-abi 0.3.1",
- "io-lifetimes",
+ "hermit-abi",
"rustix",
"windows-sys 0.48.0",
]
@@ -619,42 +476,42 @@ dependencies = [
[[package]]
name = "itoa"
-version = "1.0.6"
+version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6"
+checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
[[package]]
name = "js-sys"
-version = "0.3.63"
+version = "0.3.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790"
+checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a"
dependencies = [
"wasm-bindgen",
]
[[package]]
name = "libc"
-version = "0.2.144"
+version = "0.2.148"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1"
+checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
[[package]]
name = "linux-raw-sys"
-version = "0.3.8"
+version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519"
+checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128"
[[package]]
name = "log"
-version = "0.4.18"
+version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de"
+checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "lru"
-version = "0.10.0"
+version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "03f1160296536f10c833a82dca22267d5486734230d47bf00bf435885814ba1e"
+checksum = "718e8fae447df0c7e1ba7f5189829e63fd536945c8988d61444c19039f16b670"
dependencies = [
"hashbrown 0.13.2",
]
@@ -670,24 +527,24 @@ dependencies = [
[[package]]
name = "memchr"
-version = "2.5.0"
+version = "2.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
+checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c"
[[package]]
name = "memoffset"
-version = "0.8.0"
+version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1"
+checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c"
dependencies = [
"autocfg",
]
[[package]]
name = "miette"
-version = "5.9.0"
+version = "5.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a236ff270093b0b67451bc50a509bd1bad302cb1d3c7d37d5efe931238581fa9"
+checksum = "59bb584eaeeab6bd0226ccf3509a69d7936d148cf3d036ad350abe35e8c6856e"
dependencies = [
"is-terminal",
"miette-derive",
@@ -704,13 +561,13 @@ dependencies = [
[[package]]
name = "miette-derive"
-version = "5.9.0"
+version = "5.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4901771e1d44ddb37964565c654a3223ba41a594d02b8da471cc4464912b5cfa"
+checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.18",
+ "syn 2.0.37",
]
[[package]]
@@ -818,44 +675,41 @@ dependencies = [
name = "nufmt"
version = "0.1.0"
dependencies = [
- "anyhow",
- "clap",
- "criterion",
"env_logger",
"log",
"nu-parser",
"nu-protocol",
]
+[[package]]
+name = "nufmt_cli"
+version = "0.1.0"
+dependencies = [
+ "clap",
+ "env_logger",
+ "log",
+ "nufmt",
+]
+
[[package]]
name = "num-format"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3"
dependencies = [
- "arrayvec 0.7.2",
+ "arrayvec 0.7.4",
"itoa",
]
[[package]]
name = "num-traits"
-version = "0.2.15"
+version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
+checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2"
dependencies = [
"autocfg",
]
-[[package]]
-name = "num_cpus"
-version = "1.15.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b"
-dependencies = [
- "hermit-abi 0.2.6",
- "libc",
-]
-
[[package]]
name = "omnipath"
version = "0.1.6"
@@ -864,15 +718,9 @@ checksum = "80adb31078122c880307e9cdfd4e3361e6545c319f9b9dcafcb03acd3b51a575"
[[package]]
name = "once_cell"
-version = "1.17.2"
+version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9670a07f94779e00908f3e686eab508878ebb390ba6e604d3a284c00e8d0487b"
-
-[[package]]
-name = "oorandom"
-version = "11.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
+checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
[[package]]
name = "owo-colors"
@@ -880,39 +728,11 @@ version = "3.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f"
-[[package]]
-name = "plotters"
-version = "0.3.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2538b639e642295546c50fcd545198c9d64ee2a38620a628724a3b266d5fbf97"
-dependencies = [
- "num-traits",
- "plotters-backend",
- "plotters-svg",
- "wasm-bindgen",
- "web-sys",
-]
-
-[[package]]
-name = "plotters-backend"
-version = "0.3.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142"
-
-[[package]]
-name = "plotters-svg"
-version = "0.3.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f9a81d2759aae1dae668f783c308bc5c8ebd191ff4184aaa1b37f65a6ae5a56f"
-dependencies = [
- "plotters-backend",
-]
-
[[package]]
name = "proc-macro2"
-version = "1.0.59"
+version = "1.0.67"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6aeca18b86b413c660b781aa319e4e2648a3e6f9eadc9b47e9038e6fe9f3451b"
+checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328"
dependencies = [
"unicode-ident",
]
@@ -929,18 +749,18 @@ dependencies = [
[[package]]
name = "quote"
-version = "1.0.28"
+version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488"
+checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rayon"
-version = "1.7.0"
+version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b"
+checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1"
dependencies = [
"either",
"rayon-core",
@@ -948,14 +768,12 @@ dependencies = [
[[package]]
name = "rayon-core"
-version = "1.11.0"
+version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d"
+checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed"
dependencies = [
- "crossbeam-channel",
"crossbeam-deque",
"crossbeam-utils",
- "num_cpus",
]
[[package]]
@@ -964,7 +782,7 @@ version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
dependencies = [
- "bitflags",
+ "bitflags 1.3.2",
]
[[package]]
@@ -980,9 +798,21 @@ dependencies = [
[[package]]
name = "regex"
-version = "1.8.3"
+version = "1.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "81ca098a9821bd52d6b24fd8b10bd081f47d39c22778cafaa75a2857a62c6390"
+checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-automata",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-automata"
+version = "0.3.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795"
dependencies = [
"aho-corasick",
"memchr",
@@ -991,19 +821,18 @@ dependencies = [
[[package]]
name = "regex-syntax"
-version = "0.7.2"
+version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78"
+checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
[[package]]
name = "rustix"
-version = "0.37.19"
+version = "0.38.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d"
+checksum = "747c788e9ce8e92b12cd485c49ddf90723550b654b32508f979b71a7b1ecda4f"
dependencies = [
- "bitflags",
+ "bitflags 2.4.0",
"errno",
- "io-lifetimes",
"libc",
"linux-raw-sys",
"windows-sys 0.48.0",
@@ -1011,56 +840,47 @@ dependencies = [
[[package]]
name = "rustversion"
-version = "1.0.12"
+version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06"
+checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4"
[[package]]
name = "ryu"
-version = "1.0.13"
+version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041"
-
-[[package]]
-name = "same-file"
-version = "1.0.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
-dependencies = [
- "winapi-util",
-]
+checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
[[package]]
name = "scopeguard"
-version = "1.1.0"
+version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
+checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "serde"
-version = "1.0.163"
+version = "1.0.188"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2"
+checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
-version = "1.0.163"
+version = "1.0.188"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e"
+checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.18",
+ "syn 2.0.37",
]
[[package]]
name = "serde_json"
-version = "1.0.96"
+version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1"
+checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65"
dependencies = [
"itoa",
"ryu",
@@ -1069,9 +889,9 @@ dependencies = [
[[package]]
name = "smawk"
-version = "0.3.1"
+version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043"
+checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c"
[[package]]
name = "strip-ansi-escapes"
@@ -1109,9 +929,9 @@ dependencies = [
[[package]]
name = "supports-color"
-version = "2.0.0"
+version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4950e7174bffabe99455511c39707310e7e9b440364a2fcb1cc21521be57b354"
+checksum = "d6398cde53adc3c4557306a96ce67b302968513830a77a95b2b17305d9719a89"
dependencies = [
"is-terminal",
"is_ci",
@@ -1148,9 +968,9 @@ dependencies = [
[[package]]
name = "syn"
-version = "2.0.18"
+version = "2.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e"
+checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8"
dependencies = [
"proc-macro2",
"quote",
@@ -1159,19 +979,18 @@ dependencies = [
[[package]]
name = "sys-locale"
-version = "0.3.0"
+version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ea0b9eefabb91675082b41eb94c3ecd91af7656caee3fb4961a07c0ec8c7ca6f"
+checksum = "e801cf239ecd6ccd71f03d270d67dd53d13e90aab208bf4b8fe4ad957ea949b0"
dependencies = [
"libc",
- "windows-sys 0.45.0",
]
[[package]]
name = "sysinfo"
-version = "0.29.2"
+version = "0.29.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9557d0845b86eea8182f7b10dff120214fb6cd9fd937b6f4917714e546a38695"
+checksum = "0a18d114d420ada3a891e6bc8e96a2023402203296a47cdd65083377dad18ba5"
dependencies = [
"cfg-if",
"core-foundation-sys",
@@ -1184,9 +1003,9 @@ dependencies = [
[[package]]
name = "termcolor"
-version = "1.2.0"
+version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6"
+checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64"
dependencies = [
"winapi-util",
]
@@ -1214,50 +1033,29 @@ dependencies = [
[[package]]
name = "thiserror"
-version = "1.0.40"
+version = "1.0.49"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac"
+checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
-version = "1.0.40"
+version = "1.0.49"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"
+checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.18",
-]
-
-[[package]]
-name = "time"
-version = "0.1.45"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a"
-dependencies = [
- "libc",
- "wasi 0.10.0+wasi-snapshot-preview1",
- "winapi",
-]
-
-[[package]]
-name = "tinytemplate"
-version = "1.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc"
-dependencies = [
- "serde",
- "serde_json",
+ "syn 2.0.37",
]
[[package]]
name = "typetag"
-version = "0.2.8"
+version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6a6898cc6f6a32698cc3e14d5632a14d2b23ed9f7b11e6b8e05ce685990acc22"
+checksum = "80960fd143d4c96275c0e60b08f14b81fbb468e79bc0ef8fbda69fb0afafae43"
dependencies = [
"erased-serde",
"inventory",
@@ -1268,45 +1066,41 @@ dependencies = [
[[package]]
name = "typetag-impl"
-version = "0.2.8"
+version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2c3e1c30cedd24fc597f7d37a721efdbdc2b1acae012c1ef1218f4c7c2c0f3e7"
+checksum = "bfc13d450dc4a695200da3074dacf43d449b968baee95e341920e47f61a3b40f"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.18",
+ "syn 2.0.37",
]
[[package]]
name = "unicase"
-version = "2.6.0"
+version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
+checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89"
dependencies = [
"version_check",
]
[[package]]
name = "unicode-ident"
-version = "1.0.9"
+version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0"
+checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "unicode-linebreak"
-version = "0.1.4"
+version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c5faade31a542b8b35855fff6e8def199853b2da8da256da52f52f1316ee3137"
-dependencies = [
- "hashbrown 0.12.3",
- "regex",
-]
+checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f"
[[package]]
name = "unicode-width"
-version = "0.1.10"
+version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
+checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
[[package]]
name = "utf8-width"
@@ -1347,22 +1141,6 @@ dependencies = [
"quote",
]
-[[package]]
-name = "walkdir"
-version = "2.3.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698"
-dependencies = [
- "same-file",
- "winapi-util",
-]
-
-[[package]]
-name = "wasi"
-version = "0.10.0+wasi-snapshot-preview1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
-
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
@@ -1371,9 +1149,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"
-version = "0.2.86"
+version = "0.2.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73"
+checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342"
dependencies = [
"cfg-if",
"wasm-bindgen-macro",
@@ -1381,24 +1159,24 @@ dependencies = [
[[package]]
name = "wasm-bindgen-backend"
-version = "0.2.86"
+version = "0.2.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb"
+checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd"
dependencies = [
"bumpalo",
"log",
"once_cell",
"proc-macro2",
"quote",
- "syn 2.0.18",
+ "syn 2.0.37",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
-version = "0.2.86"
+version = "0.2.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258"
+checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@@ -1406,32 +1184,22 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
-version = "0.2.86"
+version = "0.2.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8"
+checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.18",
+ "syn 2.0.37",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
-version = "0.2.86"
+version = "0.2.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93"
-
-[[package]]
-name = "web-sys"
-version = "0.3.63"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3bdd9ef4e984da1187bf8110c5cf5b845fbc87a23602cdf912386a76fcd3a7c2"
-dependencies = [
- "js-sys",
- "wasm-bindgen",
-]
+checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1"
[[package]]
name = "winapi"
@@ -1451,9 +1219,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
-version = "0.1.5"
+version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
+checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
dependencies = [
"winapi",
]
@@ -1470,7 +1238,7 @@ version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f"
dependencies = [
- "windows-targets 0.48.0",
+ "windows-targets 0.48.5",
]
[[package]]
@@ -1488,7 +1256,7 @@ version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
dependencies = [
- "windows-targets 0.48.0",
+ "windows-targets 0.48.5",
]
[[package]]
@@ -1508,17 +1276,17 @@ dependencies = [
[[package]]
name = "windows-targets"
-version = "0.48.0"
+version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5"
+checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
dependencies = [
- "windows_aarch64_gnullvm 0.48.0",
- "windows_aarch64_msvc 0.48.0",
- "windows_i686_gnu 0.48.0",
- "windows_i686_msvc 0.48.0",
- "windows_x86_64_gnu 0.48.0",
- "windows_x86_64_gnullvm 0.48.0",
- "windows_x86_64_msvc 0.48.0",
+ "windows_aarch64_gnullvm 0.48.5",
+ "windows_aarch64_msvc 0.48.5",
+ "windows_i686_gnu 0.48.5",
+ "windows_i686_msvc 0.48.5",
+ "windows_x86_64_gnu 0.48.5",
+ "windows_x86_64_gnullvm 0.48.5",
+ "windows_x86_64_msvc 0.48.5",
]
[[package]]
@@ -1529,9 +1297,9 @@ checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
[[package]]
name = "windows_aarch64_gnullvm"
-version = "0.48.0"
+version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
+checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_msvc"
@@ -1541,9 +1309,9 @@ checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
[[package]]
name = "windows_aarch64_msvc"
-version = "0.48.0"
+version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
+checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_i686_gnu"
@@ -1553,9 +1321,9 @@ checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
[[package]]
name = "windows_i686_gnu"
-version = "0.48.0"
+version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
+checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_msvc"
@@ -1565,9 +1333,9 @@ checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
[[package]]
name = "windows_i686_msvc"
-version = "0.48.0"
+version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
+checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_x86_64_gnu"
@@ -1577,9 +1345,9 @@ checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
[[package]]
name = "windows_x86_64_gnu"
-version = "0.48.0"
+version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1"
+checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnullvm"
@@ -1589,9 +1357,9 @@ checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
[[package]]
name = "windows_x86_64_gnullvm"
-version = "0.48.0"
+version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
+checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_msvc"
@@ -1601,6 +1369,6 @@ checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
[[package]]
name = "windows_x86_64_msvc"
-version = "0.48.0"
+version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
+checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
diff --git a/Cargo.toml b/Cargo.toml
index 2e61114..5713c94 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,42 +1,3 @@
-[package]
-name = "nufmt"
-version = "0.1.0"
-edition = "2018"
-authors = ["The NuShell Contributors"]
-license = "MIT"
-description = "Formats nushell extremely fast"
-homepage = "https://github.com/nushell/nufmt"
-repository = "https://github.com/nushell/nufmt"
-readme = "README.md"
-keywords = ["nu", "nushell", "formatting", "cli"]
-categories = ["command-line-utilities"]
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-anyhow = "1.0.71"
-clap = { version = "4.3.0", optional = true, features = ["unicode", "derive"] }
-env_logger = "0.10.0"
-log = "0.4.17"
-nu-parser = "0.81.0"
-nu-protocol = "0.81.0"
-
-[dev-dependencies]
-criterion = "0.5.1"
-
-[features]
-default = ["bin"]
-bin = ["clap"]
-
-[lib]
-name = "nu_formatter"
-path = "src/lib.rs"
-
-[[bin]]
-name = "nufmt"
-path = "src/main.rs"
-required-features = ["bin"]
-
-[[bench]]
-name = "file-format-bench"
-harness = false
+[workspace]
+members = ["crates/*"]
+resolver = "1"
diff --git a/README.md b/README.md
index 3b7535a..3ac2b15 100644
--- a/README.md
+++ b/README.md
@@ -72,4 +72,4 @@ nufmt my-file1.nu my-file2.nu my-file3.nu
## Contributing
-We have a [contribution guide](docs/CONTRIBUTING.md). If you still have doubts, you can mention @AucaCoyan who is active on this repo.
+We have a [contribution guide](CONTRIBUTING.md). If you still have doubts, you can mention @AucaCoyan who is active on this repo.
diff --git a/benches/example.nu b/benches/example.nu
deleted file mode 100644
index d53c23b..0000000
--- a/benches/example.nu
+++ /dev/null
@@ -1,2399 +0,0 @@
-alias ll = ls -l
-
-
-[[status]; [UP] [UP]] | all {|el| $el.status == UP }
-[foo bar 2 baz] | all {|| ($in | describe) == 'string' }
-[0 2 4 6] | enumerate | all {|i| $i.item == $i.index * 2 }
-let cond = {|el| ($el mod 2) == 0 }; [2 4 6 8] | all $cond
-
-
-ansi green
-ansi reset
-$'(ansi red_bold)Hello(ansi reset) (ansi green_dimmed)Nu(ansi reset) (ansi purple_italic)World(ansi reset)'
-$'(ansi rb)Hello(ansi reset) (ansi gd)Nu(ansi reset) (ansi pi)World(ansi reset)'
-$"(ansi -e '3;93;41m')Hello(ansi reset)" # italic bright yellow on red background
-let bold_blue_on_red = { # `fg`, `bg`, `attr` are the acceptable keys, all other keys are considered invalid and will throw errors.
- fg: '#0000ff'
- bg: '#ff0000'
- attr: b
- }
- $"(ansi -e $bold_blue_on_red)Hello Nu World(ansi reset)"
-
-
-'Hello, Nushell! This is a gradient.' | ansi gradient --fgstart '0x40c9ff' --fgend '0xe81cff'
-'Hello, Nushell! This is a gradient.' | ansi gradient --fgstart '0x40c9ff' --fgend '0xe81cff' --bgstart '0xe81cff' --bgend '0x40c9ff'
-'Hello, Nushell! This is a gradient.' | ansi gradient --fgstart '0x40c9ff'
-'Hello, Nushell! This is a gradient.' | ansi gradient --fgend '0xe81cff'
-
-
-'file:///file.txt' | ansi link --text 'Open Me!'
-'https://www.nushell.sh/' | ansi link
-[[url text]; [https://example.com Text]] | ansi link url
-
-
-$'(ansi green)(ansi cursor_on)hello' | ansi strip
-
-
-[[status]; [UP] [DOWN] [UP]] | any {|el| $el.status == DOWN }
-[1 2 3 4] | any {|| ($in | describe) == 'string' }
-[9 8 7 6] | enumerate | any {|i| $i.item == $i.index * 2 }
-let cond = {|e| $e mod 2 == 1 }; [2 4 1 6 8] | any $cond
-
-
-[0,1,2,3] | append 4
-[0,1] | append [2,3,4]
-[0,1] | append [2,nu,4,shell]
-
-
-ast 'hello'
-ast 'ls | where name =~ README'
-ast 'for x in 1..10 { echo $x '
-
-
-
-
-2 | bits and 2
-[4 3 2] | bits and 2
-
-
-[4 3 2] | bits not
-[4 3 2] | bits not -n '2'
-[4 3 2] | bits not -s
-
-
-2 | bits or 6
-[8 3 2] | bits or 2
-
-
-17 | bits rol 2
-[5 3 2] | bits rol 2
-
-
-17 | bits ror 60
-[15 33 92] | bits ror 2 -n '1'
-
-
-2 | bits shl 7
-2 | bits shl 7 -n '1'
-0x7F | bits shl 1 -s
-[5 3 2] | bits shl 2
-
-
-8 | bits shr 2
-[15 35 2] | bits shr 2
-
-
-2 | bits xor 2
-[8 3 2] | bits xor 2
-
-
-loop { break }
-
-
-
-
-0x[1F FF AA AA] | bytes add 0x[AA]
-0x[1F FF AA AA] | bytes add 0x[AA BB] -i 1
-0x[FF AA AA] | bytes add 0x[11] -e
-0x[FF AA BB] | bytes add 0x[11 22 33] -e -i 1
-
-
- 0x[33 44 55 10 01 13] | bytes at 3..<4
- 0x[33 44 55 10 01 13] | bytes at 3..6
- 0x[33 44 55 10 01 13] | bytes at 3..
- 0x[33 44 55 10 01 13] | bytes at ..<4
- [[ColA ColB ColC]; [0x[11 12 13] 0x[14 15 16] 0x[17 18 19]]] | bytes at 1.. ColB ColC
-
-
-bytes build 0x[01 02] 0x[03] 0x[04]
-
-
-[0x[11] 0x[13 15]] | bytes collect
-[0x[11] 0x[33] 0x[44]] | bytes collect 0x[01]
-
-
-0x[1F FF AA AA] | bytes ends-with 0x[AA]
-0x[1F FF AA AA] | bytes ends-with 0x[FF AA AA]
-0x[1F FF AA AA] | bytes ends-with 0x[11]
-
-
- 0x[33 44 55 10 01 13 44 55] | bytes index-of 0x[44 55]
- 0x[33 44 55 10 01 13 44 55] | bytes index-of -e 0x[44 55]
- 0x[33 44 55 10 01 33 44 33 44] | bytes index-of -a 0x[33 44]
- 0x[33 44 55 10 01 33 44 33 44] | bytes index-of -a -e 0x[33 44]
- [[ColA ColB ColC]; [0x[11 12 13] 0x[14 15 16] 0x[17 18 19]]] | bytes index-of 0x[11] ColA ColC
-
-
-0x[1F FF AA AB] | bytes length
-[0x[1F FF AA AB] 0x[1F]] | bytes length
-
-
-0x[10 AA FF AA FF] | bytes remove 0x[10 AA]
-0x[10 AA 10 BB 10] | bytes remove -a 0x[10]
-0x[10 AA 10 BB CC AA 10] | bytes remove -e 0x[10]
-[[ColA ColB ColC]; [0x[11 12 13] 0x[14 15 16] 0x[17 18 19]]] | bytes remove 0x[11] ColA ColC
-
-
-0x[10 AA FF AA FF] | bytes replace 0x[10 AA] 0x[FF]
-0x[10 AA 10 BB 10] | bytes replace -a 0x[10] 0x[A0]
-[[ColA ColB ColC]; [0x[11 12 13] 0x[14 15 16] 0x[17 18 19]]] | bytes replace -a 0x[11] 0x[13] ColA ColC
-
-
-0x[1F FF AA AA] | bytes reverse
-0x[FF AA AA] | bytes reverse
-
-
-0x[1F FF AA AA] | bytes starts-with 0x[1F FF AA]
-0x[1F FF AA AA] | bytes starts-with 0x[1F]
-0x[1F FF AA AA] | bytes starts-with 0x[11]
-
-
-cal
-cal --full-year 2012
-cal --week-start monday
-
-
-cd ~
-cd d/s/9
-cd -
-
-
-char newline
-char --list
-(char prompt) + (char newline) + (char hamburger)
-char -u 1f378
-char -i (0x60 + 1) (0x60 + 2)
-char -u 1F468 200D 1F466 200D 1F466
-
-
-clear
-
-
-[1 2 3] | collect { |x| $x.1 }
-
-
-{ acronym:PWD, meaning:'Print Working Directory' } | columns
-[[name,age,grade]; [bill,20,a]] | columns
-[[name,age,grade]; [bill,20,a]] | columns | first
-[[name,age,grade]; [bill,20,a]] | columns | select 1
-
-
-
-
-[["Hello" "World"]; [null 3]] | compact Hello
-[["Hello" "World"]; [null 3]] | compact World
-[1, null, 2] | compact
-
-
-^external arg1 | complete
-do { ^external arg1 } | complete
-
-
-
-
-config env
-
-
-config nu
-
-
-config reset
-
-
-const x = 10
-const x = { a: 10, b: 20 }
-
-
-for i in 1..10 { if $i == 5 { continue }; print $i }
-
-
-cp myfile dir_b
-cp -r dir_a dir_b
-cp -r -v dir_a dir_b
-cp *.txt dir_a
-
-
-
-
-"2021-10-22 20:00:12 +01:00" | date format
-date now | date format "%Y-%m-%d %H:%M:%S"
-date now | date format "%Y-%m-%d %H:%M:%S"
-"2021-10-22 20:00:12 +01:00" | date format "%Y-%m-%d"
-
-
-"2021-10-22 20:00:12 +01:00" | date humanize
-
-
-date list-timezone | where timezone =~ Shanghai
-
-
-date now | date format "%Y-%m-%d %H:%M:%S"
-(date now) - 2019-05-01
-(date now) - 2019-05-01T04:12:05.20+08:00
-date now | debug
-
-
-date to-record
-date now | date to-record
-'2020-04-12T22:10:57.123+02:00' | date to-record
-
-
-date to-table
-date now | date to-table
-2020-04-12T22:10:57.000000789+02:00 | date to-table
-
-
-date now | date to-timezone '+0500'
-date now | date to-timezone local
-date now | date to-timezone US/Hawaii
-"2020-10-10 10:00:00 +02:00" | date to-timezone "+0500"
-
-
-'hello' | debug
-['hello'] | debug
-[[version patch]; ['0.1.0' false] ['0.1.1' true] ['0.2.0' false]] | debug
-
-
-^cat myfile.q | decode utf-8
-0x[00 53 00 6F 00 6D 00 65 00 20 00 44 00 61 00 74 00 61] | decode utf-16be
-
-
-'U29tZSBEYXRh' | decode base64
-'U29tZSBEYXRh' | decode base64 --binary
-
-
-'0102030A0a0B' | decode hex
-'01 02 03 0A 0a 0B' | decode hex
-
-
-def say-hi [] { echo 'hi' }; say-hi
-def say-sth [sth: string] { echo $sth }; say-sth hi
-
-
-def-env foo [] { let-env BAR = "BAZ" }; foo; $env.BAR
-
-
-ls -la | default 'nothing' target
-$env | get -i MY_ENV | default 'abc'
-[1, 2, null, 4] | default 3
-
-
-'hello' | describe
-
-
-'a b c' | detect columns -n
-$'c1 c2 c3(char nl)a b c' | detect columns
-
-
-[[a b]; [1 2] [1 4] [2 6] [2 4]]
- | dfr into-df
- | dfr group-by a
- | dfr agg [
- (dfr col b | dfr min | dfr as "b_min")
- (dfr col b | dfr max | dfr as "b_max")
- (dfr col b | dfr sum | dfr as "b_sum")
- ]
-[[a b]; [1 2] [1 4] [2 6] [2 4]]
- | dfr into-lazy
- | dfr group-by a
- | dfr agg [
- (dfr col b | dfr min | dfr as "b_min")
- (dfr col b | dfr max | dfr as "b_max")
- (dfr col b | dfr sum | dfr as "b_sum")
- ]
- | dfr collect
-
-
-
-
-
-[false false false] | dfr into-df | dfr all-false
-let s = ([5 6 2 10] | dfr into-df);
- let res = ($s > 9);
- $res | dfr all-false
-
-
-[true true true] | dfr into-df | dfr all-true
-let s = ([5 6 2 8] | dfr into-df);
- let res = ($s > 9);
- $res | dfr all-true
-
-
-let a = ([[a b]; [1 2] [3 4]] | dfr into-df);
- $a | dfr append $a
-let a = ([[a b]; [1 2] [3 4]] | dfr into-df);
- $a | dfr append $a --col
-
-
-[1 3 2] | dfr into-df | dfr arg-max
-
-
-[1 3 2] | dfr into-df | dfr arg-min
-
-
-[1 2 2 3 3] | dfr into-df | dfr arg-sort
-[1 2 2 3 3] | dfr into-df | dfr arg-sort -r
-
-
-[false true false] | dfr into-df | dfr arg-true
-
-
-[1 2 2 3 3] | dfr into-df | dfr arg-unique
-
-
-let df = ([[a b]; [one 1] [two 2] [three 3]] | dfr into-df);
- $df | dfr select (dfr arg-where ((dfr col b) >= 2) | dfr as b_arg)
-
-
-dfr col a | dfr as new_a | dfr into-nu
-
-
-["2021-12-30" "2021-12-31"] | dfr into-df | dfr as-datetime "%Y-%m-%d"
-
-
-["2021-12-30 00:00:00" "2021-12-31 00:00:00"] | dfr into-df | dfr as-datetime "%Y-%m-%d %H:%M:%S"
-
-
-[[a b]; [6 2] [4 2] [2 2]] | dfr into-df | dfr reverse | dfr cache
-
-
-dfr col a | dfr into-nu
-
-
-[[a b]; [1 2] [3 4]] | dfr into-lazy | dfr collect
-
-
-[[a b]; [1 2] [3 4]] | dfr into-df | dfr columns
-
-
-let df = ([[a b c]; [one two 1] [three four 2]] | dfr into-df);
- $df | dfr with-column ((dfr concat-str "-" [(dfr col a) (dfr col b) ((dfr col c) * 2)]) | dfr as concat)
-
-
-let other = ([za xs cd] | dfr into-df);
- [abc abc abc] | dfr into-df | dfr concatenate $other
-
-
-[abc acb acb] | dfr into-df | dfr contains ab
-
-
-
-
-
-let s = ([1 1 0 0 3 3 4] | dfr into-df);
- ($s / $s) | dfr count-null
-
-
-[1 2 3 4 5] | dfr into-df | dfr cumulative sum
-
-
-[[a b]; [1 2] [3 4]] | dfr into-df | dfr drop a
-
-
-[[a b]; [1 2] [3 4] [1 2]] | dfr into-df | dfr drop-duplicates
-
-
-let df = ([[a b]; [1 2] [3 0] [1 2]] | dfr into-df);
- let res = ($df.b / $df.b);
- let a = ($df | dfr with-column $res --name res);
- $a | dfr drop-nulls
-let s = ([1 2 0 0 3 4] | dfr into-df);
- ($s / $s) | dfr drop-nulls
-
-
-[[a b]; [1 2] [3 4]] | dfr into-df | dfr dtypes
-
-
-[[a b]; [1 2] [3 4]] | dfr into-df | dfr dummies
-[1 2 2 3 3] | dfr into-df | dfr dummies
-
-
-
-
-
-(dfr col a) > 2) | dfr expr-not
-
-
-[[a b]; [6 2] [4 2] [2 2]] | dfr into-df | dfr fetch 2
-
-
-[1 2 NaN 3 NaN] | dfr into-df | dfr fill-nan 0
-[[a b]; [0.2 1] [0.1 NaN]] | dfr into-df | dfr fill-nan 0
-
-
-[1 2 2 3 3] | dfr into-df | dfr shift 2 | dfr fill-null 0
-
-
-[[a b]; [6 2] [4 2] [2 2]] | dfr into-df | dfr filter ((dfr col a) >= 4)
-
-
-let mask = ([true false] | dfr into-df);
- [[a b]; [1 2] [3 4]] | dfr into-df | dfr filter-with $mask
-[[a b]; [1 2] [3 4]] | dfr into-df | dfr filter-with ((dfr col a) > 1)
-
-
-dfr col a | dfr first
-
-
-[[a b]; [1 2] [3 4]] | dfr into-df | dfr first
-[[a b]; [1 2] [3 4]] | dfr into-df | dfr first 2
-
-
-
-
-
-[[a b]; [1 2] [3 4]] | dfr into-df | dfr get a
-
-
-let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC');
- let df = ([$dt $dt] | dfr into-df);
- $df | dfr get-day
-
-
-let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC');
- let df = ([$dt $dt] | dfr into-df);
- $df | dfr get-hour
-
-
-let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC');
- let df = ([$dt $dt] | dfr into-df);
- $df | dfr get-minute
-
-
-let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC');
- let df = ([$dt $dt] | dfr into-df);
- $df | dfr get-month
-
-
-let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC');
- let df = ([$dt $dt] | dfr into-df);
- $df | dfr get-nanosecond
-
-
-let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC');
- let df = ([$dt $dt] | dfr into-df);
- $df | dfr get-ordinal
-
-
-let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC');
- let df = ([$dt $dt] | dfr into-df);
- $df | dfr get-second
-
-
-let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC');
- let df = ([$dt $dt] | dfr into-df);
- $df | dfr get-week
-
-
-let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC');
- let df = ([$dt $dt] | dfr into-df);
- $df | dfr get-weekday
-
-
-let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC');
- let df = ([$dt $dt] | dfr into-df);
- $df | dfr get-year
-
-
-[[a b]; [1 2] [1 4] [2 6] [2 4]]
- | dfr into-df
- | dfr group-by a
- | dfr agg [
- (dfr col b | dfr min | dfr as "b_min")
- (dfr col b | dfr max | dfr as "b_max")
- (dfr col b | dfr sum | dfr as "b_sum")
- ]
-[[a b]; [1 2] [1 4] [2 6] [2 4]]
- | dfr into-lazy
- | dfr group-by a
- | dfr agg [
- (dfr col b | dfr min | dfr as "b_min")
- (dfr col b | dfr max | dfr as "b_max")
- (dfr col b | dfr sum | dfr as "b_sum")
- ]
- | dfr collect
-
-
-[[a b];[1 2] [3 4]] | dfr into-df
-[[1 2 a] [3 4 b] [5 6 c]] | dfr into-df
-[a b c] | dfr into-df
-[true true false] | dfr into-df
-
-
-[[a b];[1 2] [3 4]] | dfr into-lazy
-
-
-dfr col a | dfr into-nu
-
-
-[[a b]; [1 2] [3 4]] | dfr into-df | dfr into-nu
-[[a b]; [1 2] [5 6] [3 4]] | dfr into-df | dfr into-nu -t -n 1
-
-
-[5 6 6 6 8 8 8] | dfr into-df | dfr is-duplicated
-[[a, b]; [1 2] [1 2] [3 3] [3 3] [1 1]] | dfr into-df | dfr is-duplicated
-
-
-let other = ([1 3 6] | dfr into-df);
- [5 6 6 6 8 8 8] | dfr into-df | dfr is-in $other
-
-
-let df = ([[a b]; [one 1] [two 2] [three 3]] | dfr into-df);
- $df | dfr with-column (dfr col a | dfr is-in [one two] | dfr as a_in)
-
-
-dfr col a | dfr is-not-null
-
-
-let s = ([5 6 0 8] | dfr into-df);
- let res = ($s / $s);
- $res | dfr is-not-null
-
-
-dfr col a | dfr is-null
-
-
-let s = ([5 6 0 8] | dfr into-df);
- let res = ($s / $s);
- $res | dfr is-null
-
-
-[5 6 6 6 8 8 8] | dfr into-df | dfr is-unique
-[[a, b]; [1 2] [1 2] [3 3] [3 3] [1 1]] | dfr into-df | dfr is-unique
-
-
-let df_a = ([[a b c];[1 "a" 0] [2 "b" 1] [1 "c" 2] [1 "c" 3]] | dfr into-lazy);
- let df_b = ([["foo" "bar" "ham"];[1 "a" "let"] [2 "c" "var"] [3 "c" "const"]] | dfr into-lazy);
- $df_a | dfr join $df_b a foo | dfr collect
-let df_a = ([[a b c];[1 "a" 0] [2 "b" 1] [1 "c" 2] [1 "c" 3]] | dfr into-df);
- let df_b = ([["foo" "bar" "ham"];[1 "a" "let"] [2 "c" "var"] [3 "c" "const"]] | dfr into-lazy);
- $df_a | dfr join $df_b a foo
-
-
-dfr col a | dfr last
-
-
-[[a b]; [1 2] [3 4]] | dfr into-df | dfr last 1
-
-
-
-
-
-dfr lit 2 | dfr into-nu
-
-
-[Abc aBc abC] | dfr into-df | dfr lowercase
-
-
-let test = ([[a b];[1 2] [3 4]] | dfr into-df);
- ls
-
-
-[[a b]; [6 2] [1 4] [4 1]] | dfr into-df | dfr max
-
-
-[[a b]; [one 2] [one 4] [two 1]]
- | dfr into-df
- | dfr group-by a
- | dfr agg (dfr col b | dfr max)
-
-
-[[a b]; [one 2] [one 4] [two 1]]
- | dfr into-df
- | dfr group-by a
- | dfr agg (dfr col b | dfr mean)
-
-
-[[a b]; [6 2] [4 2] [2 2]] | dfr into-df | dfr mean
-
-
-[[a b]; [6 2] [4 2] [2 2]] | dfr into-df | dfr median
-
-
-[[a b]; [one 2] [one 4] [two 1]]
- | dfr into-df
- | dfr group-by a
- | dfr agg (dfr col b | dfr median)
-
-
-[[a b c d]; [x 1 4 a] [y 2 5 b] [z 3 6 c]] | dfr into-df | dfr melt -c [b c] -v [a d]
-
-
-[[a b]; [one 2] [one 4] [two 1]]
- | dfr into-df
- | dfr group-by a
- | dfr agg (dfr col b | dfr min)
-
-
-[[a b]; [6 2] [1 4] [4 1]] | dfr into-df | dfr min
-
-
-dfr col a | dfr n-unique
-
-
-[1 1 2 2 3 3 4] | dfr into-df | dfr n-unique
-
-
-[true false true] | dfr into-df | dfr not
-
-
-dfr open test.csv
-
-
-dfr when ((dfr col a) > 2) 4 | dfr otherwise 5
-dfr when ((dfr col a) > 2) 4 | dfr when ((dfr col a) < 0) 6 | dfr otherwise 0
-[[a b]; [6 2] [1 4] [4 1]]
- | dfr into-lazy
- | dfr with-column (
- dfr when ((dfr col a) > 2) 4 | dfr otherwise 5 | dfr as c
- )
- | dfr with-column (
- dfr when ((dfr col a) > 5) 10 | dfr when ((dfr col a) < 2) 6 | dfr otherwise 0 | dfr as d
- )
- | dfr collect
-
-
-[[a b]; [one 2] [one 4] [two 1]]
- | dfr into-df
- | dfr group-by a
- | dfr agg (dfr col b | dfr quantile 0.5)
-
-
-[[a b]; [6 2] [1 4] [4 1]] | dfr into-df | dfr quantile 0.5
-
-
-[[a b]; [1 2] [3 4]] | dfr into-df | dfr query 'select a from df'
-
-
-[5 6 7 8] | dfr into-df | dfr rename '0' new_name
-[[a b]; [1 2] [3 4]] | dfr into-df | dfr rename a a_new
-[[a b]; [1 2] [3 4]] | dfr into-df | dfr rename [a b] [a_new b_new]
-
-
-[abc abc abc] | dfr into-df | dfr replace -p ab -r AB
-
-
-[abac abac abac] | dfr into-df | dfr replace-all -p a -r A
-
-
-[[a b]; [6 2] [4 2] [2 2]] | dfr into-df | dfr reverse
-
-
-[1 2 3 4 5] | dfr into-df | dfr rolling sum 2 | dfr drop-nulls
-[1 2 3 4 5] | dfr into-df | dfr rolling max 2 | dfr drop-nulls
-
-
-[[a b]; [1 2] [3 4]] | dfr into-df | dfr sample -n 1
-[[a b]; [1 2] [3 4] [5 6]] | dfr into-df | dfr sample -f 0.5 -e
-
-
-[[a b]; [6 2] [4 2] [2 2]] | dfr into-df | dfr select a
-
-
-let s = ([1 2 2 3 3] | dfr into-df | dfr shift 2);
- let mask = ($s | dfr is-null);
- $s | dfr set 0 --mask $mask
-
-
-let series = ([4 1 5 2 4 3] | dfr into-df);
- let indices = ([0 2] | dfr into-df);
- $series | dfr set-with-idx 6 -i $indices
-
-
-[[a b]; [1 2] [3 4]] | dfr into-df | dfr shape
-
-
-[1 2 2 3 3] | dfr into-df | dfr shift 2 | dfr drop-nulls
-
-
-[[a b]; [1 2] [3 4]] | dfr into-df | dfr slice 0 1
-
-
-[[a b]; [6 2] [1 4] [4 1]] | dfr into-df | dfr sort-by a
-[[a b]; [6 2] [1 1] [1 4] [2 4]] | dfr into-df | dfr sort-by [a b] -r [false true]
-
-
-[[a b]; [one 2] [one 2] [two 1] [two 1]]
- | dfr into-df
- | dfr group-by a
- | dfr agg (dfr col b | dfr std)
-
-
-[[a b]; [6 2] [4 2] [2 2]] | dfr into-df | dfr std
-
-
-[a ab abc] | dfr into-df | dfr str-lengths
-
-
-[abcded abc321 abc123] | dfr into-df | dfr str-slice 1 -l 2
-
-
-let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC');
- let df = ([$dt $dt] | dfr into-df);
- $df | dfr strftime "%Y/%m/%d"
-
-
-[[a b]; [one 2] [one 4] [two 1]]
- | dfr into-df
- | dfr group-by a
- | dfr agg (dfr col b | dfr sum)
-
-
-[[a b]; [6 2] [1 4] [4 1]] | dfr into-df | dfr sum
-
-
-[[a b]; [1 1] [1 1]] | dfr into-df | dfr summary
-
-
-let df = ([[a b]; [4 1] [5 2] [4 3]] | dfr into-df);
- let indices = ([0 2] | dfr into-df);
- $df | dfr take $indices
-let series = ([4 1 5 2 4 3] | dfr into-df);
- let indices = ([0 2] | dfr into-df);
- $series | dfr take $indices
-
-
-[[a b]; [1 2] [3 4]] | dfr into-df | dfr to-arrow test.arrow
-
-
-[[a b]; [1 2] [3 4]] | dfr into-df | dfr to-csv test.csv
-[[a b]; [1 2] [3 4]] | dfr into-df | dfr to-csv test.csv -d '|'
-
-
-[[a b]; [1 2] [3 4]] | dfr into-df | dfr to-parquet test.parquet
-
-
-[2 2 2 2 2] | dfr into-df | dfr unique
-col a | unique
-
-
-[Abc aBc abC] | dfr into-df | dfr uppercase
-
-
-[5 5 5 5 6 6] | dfr into-df | dfr value-counts
-
-
-[[a b]; [6 2] [4 2] [2 2]] | dfr into-df | dfr var
-
-
-[[a b]; [one 2] [one 2] [two 1] [two 1]]
- | dfr into-df
- | dfr group-by a
- | dfr agg (dfr col b | dfr var)
-
-
-dfr when ((dfr col a) > 2) 4
-dfr when ((dfr col a) > 2) 4 | dfr when ((dfr col a) < 0) 6
-[[a b]; [6 2] [1 4] [4 1]]
- | dfr into-lazy
- | dfr with-column (
- dfr when ((dfr col a) > 2) 4 | dfr otherwise 5 | dfr as c
- )
- | dfr with-column (
- dfr when ((dfr col a) > 5) 10 | dfr when ((dfr col a) < 2) 6 | dfr otherwise 0 | dfr as d
- )
- | dfr collect
-
-
-[[a b]; [1 2] [3 4]]
- | dfr into-df
- | dfr with-column ([5 6] | dfr into-df) --name c
-[[a b]; [1 2] [3 4]]
- | dfr into-lazy
- | dfr with-column [
- ((dfr col a) * 2 | dfr as "c")
- ((dfr col a) * 3 | dfr as "d")
- ]
- | dfr collect
-
-
-do { echo hello }
-let text = "I am enclosed"; let hello = {|| echo $text}; do $hello
-do -i { thisisnotarealcommand }
-do -s { thisisnotarealcommand }
-do -p { nu -c 'exit 1' }; echo "I'll still run"
-do -c { nu -c 'exit 1' } | myscarycommand
-do {|x| 100 + $x } 77
-77 | do {|x| 100 + $in }
-
-
-[0,1,2,3] | drop
-[0,1,2,3] | drop 0
-[0,1,2,3] | drop 2
-[[a, b]; [1, 2] [3, 4]] | drop 1
-
-
-[[lib, extension]; [nu-lib, rs] [nu-core, rb]] | drop column
-
-
-[sam,sarah,2,3,4,5] | drop nth 0 1 2
-[0,1,2,3,4,5] | drop nth 0 1 2
-[0,1,2,3,4,5] | drop nth 0 2 4
-[0,1,2,3,4,5] | drop nth 2 0 4
-[first second third fourth fifth] | drop nth (1..3)
-[0,1,2,3,4,5] | drop nth 1..
-[0,1,2,3,4,5] | drop nth 3..
-
-
-du
-
-
-[1 2 3] | each {|e| 2 * $e }
-{major:2, minor:1, patch:4} | values | each {|| into string }
-[1 2 3 2] | each {|e| if $e == 2 { "two" } }
-[1 2 3] | enumerate | each {|e| if $e.item == 2 { $"found 2 at ($e.index)!"} }
-[1 2 3] | each --keep-empty {|e| if $e == 2 { "found 2!"} }
-
-
-[1 2 3 2 1] | each while {|e| if $e < 3 { $e * 2 } }
-[1 2 stop 3 4] | each while {|e| if $e != 'stop' { $"Output: ($e)" } }
-[1 2 3] | enumerate | each while {|e| if $e.item < 2 { $"value ($e.item) at ($e.index)!"} }
-
-
-echo 1 2 3
-echo $in
-
-
-"負けると知って戦うのが、遥かに美しいのだ" | encode shift-jis
-"🎈" | encode -i shift-jis
-
-
-0x[09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0] | encode base64
-'Some Data' | encode base64
-'Some Data' | encode base64 --character-set binhex
-
-
-0x[09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0] | encode hex
-
-
-enter ../dir-foo
-
-
-[a, b, c] | enumerate
-
-
-error make {msg: "my custom error message"}
-error make {
- msg: "my custom error message"
- label: {
- text: "my custom label text" # not mandatory unless $.label exists
- start: 123 # not mandatory unless $.label.end is set
- end: 456 # not mandatory unless $.label.start is set
- }
- }
-def foo [x] {
- let span = (metadata $x).span;
- error make {
- msg: "this is fishy"
- label: {
- text: "fish right here"
- start: $span.start
- end: $span.end
- }
- }
- }
-
-
-[1 2 3 4 5] | every 2
-[1 2 3 4 5] | every 2 --skip
-
-
-exec ps aux
-exec nautilus
-
-
-exit
-exit --now
-
-
-explain {|| ls | sort-by name type -i | get name } | table -e
-
-
-sys | explore
-ls | explore --head false
-glob *.md | each {|| open } | explore -i
-open file.json | explore -p | to json | save part.json
-
-
-module utils { export def my-command [] { "hello" } }; use utils my-command; my-command
-
-
-module spam { export alias ll = ls -l }
-
-
-module spam { export def foo [] { "foo" } }; use spam foo; foo
-
-
-module foo { export def-env bar [] { let-env FOO_BAR = "BAZ" } }; use foo bar; bar; $env.FOO_BAR
-
-
-export extern echo [text: string]
-
-
-export old-alias ll = ls -l
-
-
-module spam { export def foo [] { "foo" } }
- module eggs { export use spam foo }
- use eggs foo
- foo
-
-
-
-export-env { let-env SPAM = 'eggs' }
-export-env { let-env SPAM = 'eggs' }; $env.SPAM
-
-
-extern echo [text: string]
-
-
-'nushell' | fill -a l -c '─' -w 15
-'nushell' | fill -a r -c '─' -w 15
-'nushell' | fill -a m -c '─' -w 15
-1 | fill --alignment right --character '0' --width 5
-1.1 | fill --alignment center --character '0' --width 5
-1kib | fill --alignment middle --character '0' --width 10
-
-
-[1 2] | filter {|x| $x > 1}
-[{a: 1} {a: 2}] | filter {|x| $x.a > 1}
-let cond = {|x| $x.a > 1}; [{a: 1} {a: 2}] | filter $cond
-
-
-ls | find toml md sh
-'Cargo.toml' | find toml
-[1 5 3kb 4 3Mb] | find 5 3kb
-[moe larry curly] | find l
-[abc bde arc abf] | find --regex "ab"
-[aBc bde Arc abf] | find --regex "ab" -i
-[[version name]; ['0.1.0' nushell] ['0.1.1' fish] ['0.2.0' zsh]] | find -r "nu"
-[[foo bar]; [abc 123] [def 456]] | find 123 | get bar | ansi strip
-
-
-[1 2 3] | first
-[1 2 3] | first 2
-0x[01 23 45] | first 2
-
-
-[[N, u, s, h, e, l, l]] | flatten
-[[N, u, s, h, e, l, l]] | flatten | first
-[[origin, people]; [Ecuador, ([[name, meal]; ['Andres', 'arepa']])]] | flatten --all | get meal
-[[origin, crate, versions]; [World, ([[name]; ['nu-cli']]), ['0.21', '0.22']]] | flatten versions --all | last | get versions
-{ a: b, d: [ 1 2 3 4 ], e: [ 4 3 ] } | flatten d --all
-
-
-42 | fmt
-
-
-for x in [1 2 3] { print ($x * $x) }
-for $x in 1..3 { print $x }
-for $it in ['bob' 'fred'] --numbered { print $"($it.index) is ($it.item)" }
-
-
-ls | format '{name}: {size}'
-[[col1, col2]; [v1, v2] [v3, v4]] | format '{col2}'
-
-
-ls | format filesize KB size
-du | format filesize B apparent
-4Gb | format filesize MB
-
-
-
-
-"ColA,ColB
-1,2" | from csv
-open data.txt | from csv --noheaders
-open data.txt | from csv --separator ';'
-open data.txt | from csv --comment '#'
-open data.txt | from csv --trim all
-open data.txt | from csv --trim headers
-open data.txt | from csv --trim fields
-
-
-'From: test@email.com
-Subject: Welcome
-To: someone@somewhere.com
-Test' | from eml
-'From: test@email.com
-Subject: Welcome
-To: someone@somewhere.com
-Test' | from eml -b 1
-
-
-'BEGIN:VCALENDAR
- END:VCALENDAR' | from ics
-
-
-'[foo]
-a=1
-b=2' | from ini
-
-
-'{ "a": 1 }' | from json
-'{ "a": 1, "b": [1, 2] }' | from json
-
-
-'{ a:1 }' | from nuon
-'{ a:1, b: [1, 2] }' | from nuon
-
-
-open --raw test.ods | from ods
-open --raw test.ods | from ods -s [Spreadsheet1]
-
-
-open --raw file.parquet | from parquet
-open file.parquet
-
-
-
-
-'FOO BAR
-1 2' | from ssv
-'FOO BAR
-1 2' | from ssv -n
-
-
-'a = 1' | from toml
-'a = 1
-b = [1, 2]' | from toml
-
-
-"ColA ColB
-1 2" | from tsv
-$'c1(char tab)c2(char tab)c3(char nl)1(char tab)2(char tab)3' | save tsv-data | open tsv-data | from tsv
-$'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv -n
-$'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv --trim all
-$'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv --trim headers
-$'a1(char tab)b1(char tab)c1(char nl)a2(char tab)b2(char tab)c2' | save tsv-data | open tsv-data | from tsv --trim fields
-
-
-'bread=baguette&cheese=comt%C3%A9&meat=ham&fat=butter' | from url
-
-
-'BEGIN:VCARD
-N:Foo
-FN:Bar
-EMAIL:foo@bar.com
-END:VCARD' | from vcf
-
-
-open --raw test.xlsx | from xlsx
-open --raw test.xlsx | from xlsx -s [Spreadsheet1]
-
-
-'
-
- Event
-' | from xml
-
-
-'a: 1' | from yaml
-'[ a: 1, b: [1, 2] ]' | from yaml
-
-
-'a: 1' | from yaml
-'[ a: 1, b: [1, 2] ]' | from yaml
-
-
-g
-mkdir foo bar; enter foo; enter ../bar; g 1
-shells; g 2
-mkdir foo bar; enter foo; enter ../bar; g -
-
-
-[0 1 2] | get 1
-[{A: A0}] | get A
-[{A: A0}] | get 0.A
-ls | get name.2
-ls | get 2.name
-sys | get cpu
-$env | get paTH
-$env | get -s Path
-
-
-glob *.rs
-glob **/*.{rs,toml} --depth 2
-glob "[Cc]*"
-glob "{a?c,x?z}"
-glob "(?i)c*"
-glob "[!cCbMs]*"
-glob
-glob <[a-d]:1,10>
-glob "[A-Z]*" --no-file --no-symlink
-
-
-[1 2 3 a b c] | grid
-[1 2 3 a b c] | wrap name | grid
-{name: 'foo', b: 1, c: 2} | grid
-[{name: 'A', v: 1} {name: 'B', v: 2} {name: 'C', v: 3}] | grid
-[[name patch]; [0.1.0 false] [0.1.1 true] [0.2.0 false]] | grid
-
-
-[1 2 3 4] | group 2
-
-
-ls | group-by type
-['1' '3' '1' '3' '2' '1' '1'] | group-by
-
-
-
-
-
-
-
-
-'abcdefghijklmnopqrstuvwxyz' | hash md5
-'abcdefghijklmnopqrstuvwxyz' | hash md5 --binary
-open ./nu_0_24_1_windows.zip | hash md5
-
-
-'abcdefghijklmnopqrstuvwxyz' | hash sha256
-'abcdefghijklmnopqrstuvwxyz' | hash sha256 --binary
-open ./nu_0_24_1_windows.zip | hash sha256
-
-
-"a b c|1 2 3" | split row "|" | split column " " | headers
-"a b c|1 2 3|1 2 3 4" | split row "|" | split column " " | headers
-
-
-help match
-help str lpad
-help --find char
-
-
-help aliases
-help aliases my-alias
-help aliases --find my-alias
-
-
-
-
-help externs
-help externs smth
-help externs --find smth
-
-
-help modules
-help modules my-module
-help modules --find my-module
-
-
-
-
-alias lll = ls -l; hide lll
-def say-hi [] { echo 'Hi!' }; hide say-hi
-
-
-let-env HZ_ENV_ABC = 1; hide-env HZ_ENV_ABC; 'HZ_ENV_ABC' in (env).name
-
-
-
-
-ls | histogram type
-ls | histogram type freq
-[1 2 1] | histogram
-[1 2 3 1 1 1 2 2 1 1] | histogram --percentage-type relative
-
-
-history | length
-history | last 5
-history | wrap cmd | where cmd =~ cargo
-
-
-history session
-
-
-
-
-http delete https://www.example.com
-http delete -u myuser -p mypass https://www.example.com
-http delete -H [my-header-key my-header-value] https://www.example.com
-http delete -d 'body' https://www.example.com
-http delete -t application/json -d { field: value } https://www.example.com
-
-
-http get https://www.example.com
-http get -u myuser -p mypass https://www.example.com
-http get -H [my-header-key my-header-value] https://www.example.com
-
-
-http head https://www.example.com
-http head -u myuser -p mypass https://www.example.com
-http head -H [my-header-key my-header-value] https://www.example.com
-
-
-http patch https://www.example.com 'body'
-http patch -u myuser -p mypass https://www.example.com 'body'
-http patch -H [my-header-key my-header-value] https://www.example.com
-http patch -t application/json https://www.example.com { field: value }
-
-
-http post https://www.example.com 'body'
-http post -u myuser -p mypass https://www.example.com 'body'
-http post -H [my-header-key my-header-value] https://www.example.com
-http post -t application/json https://www.example.com { field: value }
-
-
-http put https://www.example.com 'body'
-http put -u myuser -p mypass https://www.example.com 'body'
-http put -H [my-header-key my-header-value] https://www.example.com
-http put -t application/json https://www.example.com { field: value }
-
-
-if 2 < 3 { 'yes!' }
-if 5 < 3 { 'yes!' } else { 'no!' }
-if 5 < 3 { 'yes!' } else if 4 < 5 { 'no!' } else { 'okay!' }
-
-
-echo done | ignore
-
-
-
-
-let user_input = (input)
-
-
-{'name': 'nu', 'stars': 5} | insert alias 'Nushell'
-[[project, lang]; ['Nushell', 'Rust']] | insert type 'shell'
-[[foo]; [7] [8] [9]] | enumerate | insert bar {|e| $e.item.foo + $e.index } | flatten
-
-
-ls | inspect | get name | inspect
-
-
-
-
-'This is a string that is exactly 52 characters long.' | into binary
-1 | into binary
-true | into binary
-ls | where name == LICENSE | get size | into binary
-ls | where name == LICENSE | get name | path expand | into binary
-1.234 | into binary
-
-
-[[value]; ['false'] ['1'] [0] [1.0] [true]] | into bool value
-true | into bool
-1 | into bool
-0.3 | into bool
-'0.0' | into bool
-'true' | into bool
-
-
-'27.02.2021 1:55 pm +0000' | into datetime
-'2021-02-27T13:55:40.2246+00:00' | into datetime
-'20210227_135540+0000' | into datetime -f '%Y%m%d_%H%M%S%z'
-1614434140123456789 | into datetime --offset -5
-1614434140 * 1_000_000_000 | into datetime
-
-
-[[num]; ['5.01']] | into decimal num
-'1.345' | into decimal
-'-5.9' | into decimal
-true | into decimal
-
-
-[[value]; ['1sec'] ['2min'] ['3hr'] ['4day'] ['5wk']] | into duration value
-'7min' | into duration
-'7min' | into duration --convert sec
-420sec | into duration
-420sec | into duration --convert ms
-1000000µs | into duration --convert sec
-1sec | into duration --convert µs
-1sec | into duration --convert us
-
-
-[[bytes]; ['5'] [3.2] [4] [2kb]] | into filesize bytes
-'2' | into filesize
-8.3 | into filesize
-5 | into filesize
-4KB | into filesize
-
-
-[[num]; ['-5'] [4] [1.5]] | into int num
-'2' | into int
-5.9 | into int
-'5.9' | into int
-4KB | into int
-[false, true] | into int
-1983-04-13T12:09:14.123456789-05:00 | into int
-'1101' | into int -r 2
-'FF' | into int -r 16
-'0o10132' | into int
-'0010132' | into int
-'0010132' | into int -r 8
-
-
-[[value]; [false]] | into record
-[1 2 3] | into record
-0..2 | into record
--500day | into record
-{a: 1, b: 2} | into record
-2020-04-12T22:10:57+02:00 | into record
-
-
-ls | into sqlite my_ls.db
-ls | into sqlite my_ls.db -t my_table
-[[name]; [-----] [someone] [=====] [somename] ['(((((']] | into sqlite filename.db
-[one 2 5.2 six true 100mib 25sec] | into sqlite variety.db
-
-
-5 | into string -d 3
-1.7 | into string -d 0
-1.7 | into string -d 1
-1.734 | into string -d 2
-1.734 | into string -d -2
-4.3 | into string
-'1234' | into string
-true | into string
-ls Cargo.toml | get name | into string
-1KiB | into string
-
-
-if is-admin { "iamroot" } else { "iamnotroot" }
-
-
-'' | is-empty
-[] | is-empty
-[[meal size]; [arepa small] [taco '']] | is-empty meal size
-
-
-{ new: york, san: francisco } | items {|key, value| echo $'($key) ($value)' }
-
-
-[{a: 1 b: 2}] | join [{a: 1 c: 3}] a
-
-
-open -r test.json | json path '$.store.book[*].author'
-
-
-
-
-keybindings default
-
-
-keybindings list -m
-keybindings list -e -d
-keybindings list
-
-
-keybindings listen
-
-
-ps | sort-by mem | last | kill $in.pid
-kill --force 12345
-kill -s 2 12345
-
-
-[1,2,3] | last 2
-[1,2,3] | last
-
-
-[1 2 3 4 5] | length
-[{columnA: A0 columnB: B0}] | length -c
-
-
-let x = 10
-let x = 10 + 100
-let x = if false { -1 } else { 1 }
-
-
-let-env MY_ENV_VAR = 1; $env.MY_ENV_VAR
-
-
-$"two\nlines" | lines
-
-
-{NAME: ABE, AGE: UNKNOWN} | load-env; $env.NAME
-load-env {NAME: ABE, AGE: UNKNOWN}; $env.NAME
-
-
-mut x = 0; loop { if $x > 10 { break }; $x = $x + 1 }; $x
-
-
-ls
-ls subdir
-ls -f ..
-ls *.rs
-ls -s | where name !~ bar
-ls -a ~ | where type == dir
-ls -as ~ | where type == dir and modified < ((date now) - 7day)
-['/path/to/directory' '/path/to/file'] | each {|| ls -D $in } | flatten
-
-
-match 3 { 1..10 => 'yes!' }
-match {a: 100} { {a: $my_value} => { $my_value } }
-match 3 { 1 => { 'yes!' }, _ => { 'no!' } }
-match [1, 2, 3] { [$a, $b, $c] => { $a + $b + $c }, _ => 0 }
-{a: {b: 3}} | match $in {{a: { $b }} => ($b + 10) }
-
-
-
-
-[-50 -100.0 25] | math abs
-
-
-1 | math arccos
--1 | math arccos -d
-
-
-1 | math arccosh
-
-
-1 | math arcsin
-1 | math arcsin -d
-
-
-0 | math arcsinh
-
-
-1 | math arctan
--1 | math arctan -d
-
-
-1 | math arctanh
-
-
-[-50 100.0 25] | math avg
-
-
-[1.5 2.3 -3.1] | math ceil
-
-
-math pi | math cos
-[0 90 180 270 360] | math cos -d
-
-
-1 | math cosh
-
-
-math e | math round --precision 3
-
-
-
-
-0 | math exp
-1 | math exp
-
-
-[1.5 2.3 -3.1] | math floor
-
-
-math e | math ln
-
-
-100 | math log 10
-[16 8 4] | math log 2
-
-
-[-50 100 25] | math max
-[{a: 1 b: 3} {a: 2 b: -1}] | math max
-
-
-[3 8 9 12 12 15] | math median
-[{a: 1 b: 3} {a: 2 b: -1} {a: -3 b: 5}] | math median
-
-
-[-50 100 25] | math min
-[{a: 1 b: 3} {a: 2 b: -1}] | math min
-
-
-[3 3 9 12 12 15] | math mode
-[{a: 1 b: 3} {a: 2 b: -1} {a: 1 b: 5}] | math mode
-
-
-math pi | math round --precision 2
-
-
-[2 3 3 4] | math product
-
-
-[1.5 2.3 -3.1] | math round
-[1.555 2.333 -3.111] | math round -p 2
-
-
-(math pi) / 2 | math sin
-[0 90 180 270 360] | math sin -d | math round --precision 4
-
-
-1 | math sinh
-
-
-[9 16] | math sqrt
-
-
-[1 2 3 4 5] | math stddev
-[1 2 3 4 5] | math stddev -s
-
-
-[1 2 3] | math sum
-ls | get size | math sum
-
-
-(math pi) / 4 | math tan
-[-45 0 45] | math tan -d
-
-
-(math pi) * 10 | math tanh
-
-
-math tau | math round --precision 2
-
-
-[1 2 3 4 5] | math variance
-[1 2 3 4 5] | math variance -s
-
-
-[a b c] | wrap name | merge ( [1 2 3] | wrap index )
-{a: 1, b: 2} | merge {c: 3}
-[{columnA: A0 columnB: B0}] | merge [{columnA: 'A0*'}]
-
-
-let a = 42; metadata $a
-ls | metadata
-
-
-mkdir foo
-mkdir -v foo/bar foo2
-
-
-module spam { export def foo [] { "foo" } }; use spam foo; foo
-module foo { export-env { let-env FOO = "BAZ" } }; use foo; $env.FOO
-module foo { export def-env bar [] { let-env FOO_BAR = "BAZ" } }; use foo bar; bar; $env.FOO_BAR
-
-
-[[name value index]; [foo a 1] [bar b 2] [baz c 3]] | move index --before name
-[[name value index]; [foo a 1] [bar b 2] [baz c 3]] | move value name --after index
-{ name: foo, value: a, index: 1 } | move name --before index
-
-
-mut x = 10; $x = 12
-mut a = {b:{c:1}}; $a.b.c = 2
-mut x = 10 + 100
-mut x = if false { -1 } else { 1 }
-
-
-mv before.txt after.txt
-mv test.txt my/subdirectory
-mv *.txt my/subdirectory
-
-
-mkdir foo bar; enter foo; enter ../bar; n
-n
-
-
-nu-check script.nu
-nu-check --as-module module.nu
-nu-check -d script.nu
-open foo.nu | nu-check -d script.nu
-open module.nu | lines | nu-check -d --as-module module.nu
-$'two(char nl)lines' | nu-check
-nu-check -a script.nu
-open foo.nu | lines | nu-check -ad
-
-
-'let x = 3' | nu-highlight
-
-
-old-alias ll = ls -l
-old-alias customs = ($nu.scope.commands | where is_custom | get command)
-
-
-open myfile.json
-open myfile.json --raw
-'myfile.txt' | open
-open myfile.txt --raw | decode utf-8
-
-
-
-
-module spam { export def foo [] { "foo" } }
- overlay use spam
- def bar [] { "bar" }
- overlay hide spam --keep-custom
- bar
-
-'export alias f = "foo"' | save spam.nu
- overlay use spam.nu
- overlay hide spam
-module spam { export-env { let-env FOO = "foo" } }
- overlay use spam
- overlay hide
-overlay new spam
- cd some-dir
- overlay hide --keep-env [ PWD ] spam
-
-
-module spam { export def foo [] { "foo" } }
- overlay use spam
- overlay list | last
-
-
-overlay new spam
-
-
-module spam { export def foo [] { "foo" } }
- overlay use spam
- foo
-module spam { export def foo [] { "foo" } }
- overlay use spam as spam_new
- foo
-'export def foo { "foo" }'
- overlay use --prefix spam
- spam foo
-'export-env { let-env FOO = "foo" }' | save spam.nu
- overlay use spam.nu
- $env.FOO
-
-
-mkdir foo bar; enter foo; enter ../bar; p
-p
-
-
-[1 2 3] | par-each {|| 2 * $in }
-[foo bar baz] | par-each {|e| $e + '!' } | sort
-1..3 | enumerate | par-each {|p| update item ($p.item * 2)} | sort-by item | get item
-[1 2 3] | enumerate | par-each { |e| if $e.item == 2 { $"found 2 at ($e.index)!"} }
-
-
-"hi there" | parse "{foo} {bar}"
-"hi there" | parse -r '(?P\w+) (?P\w+)'
-"foo bar." | parse -r '\s*(?\w+)(?=\.)'
-"foo! bar." | parse -r '(\w+)(?=\.)|(\w+)(?=!)'
-" @another(foo bar) " | parse -r '\s*(?<=[() ])(@\w+)(\([^)]*\))?\s*'
-"abcd" | parse -r '^a(bc(?=d)|b)cd$'
-
-
-
-
-'/home/joe/test.txt' | path basename
-[[name];[/home/joe]] | path basename -c [ name ]
-'/home/joe/test.txt' | path basename -r 'spam.png'
-
-
-'/home/joe/code/test.txt' | path dirname
-ls ('.' | path expand) | path dirname -c [ name ]
-'/home/joe/code/test.txt' | path dirname -n 2
-'/home/joe/code/test.txt' | path dirname -n 2 -r /home/viking
-
-
-'/home/joe/todo.txt' | path exists
-ls | path exists -c [ name ]
-
-
-'/home/joe/foo/../bar' | path expand
-ls | path expand -c [ name ]
-'foo/../bar' | path expand
-
-
-'/home/viking' | path join spam.txt
-'/home/viking' | path join spams this_spam.txt
-ls | path join spam.txt -c [ name ]
-[ '/' 'home' 'viking' 'spam.txt' ] | path join
-[[ parent stem extension ]; [ '/home/viking' 'spam' 'txt' ]] | path join
-
-
-'/home/viking/spam.txt' | path parse
-'/home/viking/spam.tar.gz' | path parse -e tar.gz | upsert extension { 'txt' }
-'/etc/conf.d' | path parse -e ''
-ls | path parse -c [ name ]
-
-
-'/home/viking' | path relative-to '/home'
-ls ~ | path relative-to ~ -c [ name ]
-'eggs/bacon/sausage/spam' | path relative-to 'eggs/bacon/sausage'
-
-
-'/home/viking/spam.txt' | path split
-ls ('.' | path expand) | path split -c [ name ]
-
-
-'.' | path type
-ls | path type -c [ name ]
-
-
-
-
-
-
-pnet
-
-
-port 3121 4000
-port
-
-
-[1,2,3,4] | prepend 0
-[2,3,4] | prepend [0,1]
-[2,nu,4,shell] | prepend [0,1,rocks]
-
-
-print "hello world"
-print (2 + 3)
-
-
-def spam [] { "spam" }; profile {|| spam | str length } -d 2 --source
-
-
-ps
-ps | sort-by mem | last 5
-ps | sort-by cpu | last 3
-ps | where name =~ 'nu'
-ps | where pid == $nu.pid | get ppid
-
-
-
-
-open foo.db | query db "SELECT * FROM Bar"
-
-
-
-
-http get https://phoronix.com | query web -q 'header'
-http get https://en.wikipedia.org/wiki/List_of_cities_in_India_by_population
- | query web -t [Rank City 'Population(2011)[3]' 'Population(2001)' 'State or union territory']
-http get https://www.nushell.sh | query web -q 'h2, h2 + p' | group 2 | each {rotate --ccw tagline description} | flatten
-http get https://example.org | query web --query a --attribute href
-
-
-
-
-
-
-random bool
-random bool --bias 0.75
-
-
-random chars
-random chars -l 20
-
-
-random decimal
-random decimal ..500
-random decimal 100000..
-random decimal 1.0..1.1
-
-
-random dice
-random dice -d 10 -s 12
-
-
-random integer
-random integer ..500
-random integer 100000..
-random integer 1..10
-
-
-random uuid
-
-
-[0,1,2,3,4,5] | range 4..5
-[0,1,2,3,4,5] | range (-2)..
-[0,1,2,3,4,5] | range (-3)..-2
-
-
-[ 1 2 3 4 ] | reduce {|it, acc| $it + $acc }
-[ 8 7 6 ] | enumerate | reduce -f 0 {|it, acc| $acc + $it.item + $it.index }
-[ 1 2 3 4 ] | reduce -f 10 {|it, acc| $acc + $it }
-[ i o t ] | reduce -f "Arthur, King of the Britons" {|it, acc| $acc | str replace -a $it "X" }
-['foo.gz', 'bar.gz', 'baz.gz'] | enumerate | reduce -f '' {|str all| $"($all)(if $str.index != 0 {'; '})($str.index + 1)-($str.item)" }
-
-
-"hello world" | regex '(?P\w+) (?P\w+)'
-
-
-register ~/.cargo/bin/nu_plugin_query
-let plugin = ((which nu).path.0 | path dirname | path join 'nu_plugin_query'); nu -c $'register ($plugin); version'
-
-
-ls | reject modified
-[[a, b]; [1, 2]] | reject a
-{a: 1, b: 2} | reject a
-{a: {b: 3, c: 5}} | reject a.b
-
-
-[[a, b]; [1, 2]] | rename my_column
-[[a, b, c]; [1, 2, 3]] | rename eggs ham bacon
-[[a, b, c]; [1, 2, 3]] | rename -c [a ham]
-{a: 1 b: 2} | rename x y
-
-
-def foo [] { return }
-
-
-[0,1,2,3] | reverse
-[{a: 1} {a: 2}] | reverse
-
-
-rm file.txt
-rm --trash file.txt
-rm --permanent file.txt
-rm --force file.txt
-ls | where size == 0KB and type == file | each { rm $in.name } | null
-
-
-
-
-[[a b]; [1 2] [3 4] [5 6]] | roll down
-
-
-{a:1 b:2 c:3} | roll left
-[[a b c]; [1 2 3] [4 5 6]] | roll left
-[[a b c]; [1 2 3] [4 5 6]] | roll left --cells-only
-
-
-{a:1 b:2 c:3} | roll right
-[[a b c]; [1 2 3] [4 5 6]] | roll right
-[[a b c]; [1 2 3] [4 5 6]] | roll right --cells-only
-
-
-[[a b]; [1 2] [3 4] [5 6]] | roll up
-
-
-{a:1, b:2} | rotate
-[[a b]; [1 2] [3 4] [5 6]] | rotate
-[[a b]; [1 2]] | rotate col_a col_b
-[[a b]; [1 2]] | rotate --ccw
-[[a b]; [1 2] [3 4] [5 6]] | rotate --ccw
-[[a b]; [1 2]] | rotate --ccw col_a col_b
-
-
-run-external "echo" "-n" "hello"
-run-external --redirect-stdout "echo" "-n" "hello" | split chars
-
-
-'save me' | save foo.txt
-'append me' | save --append foo.txt
-{ a: 1, b: 2 } | save foo.json
-do -i {} | save foo.txt --stderr foo.txt
-do -i {} | save foo.txt --stderr bar.txt
-
-
-open foo.db | schema
-
-
-[{a: a b: b}] | select a
-{a: a b: b} | select a
-ls | select name
-ls | select 0 1 2 3
-
-
-seq 1 10
-seq 1.0 0.1 2.0
-seq 1 5 | str join '|'
-
-
-seq char a e
-seq char a e | str join '|'
-
-
-seq date --days 10
-seq date --days 10 -r
-seq date --days 10 -o '%m/%d/%Y' -r
-seq date -b '2020-01-01' -e '2020-01-10'
-seq date -b '2020-01-01' -e '2020-01-31' -n 5
-
-
-enter ..; shells
-shells | where active == true
-
-
-[[version patch]; ['1.0.0' false] ['3.0.1' true] ['2.0.0' false]] | shuffle
-
-
-"There are seven words in this sentence" | size
-'今天天气真好' | size
-"Amélie Amelie" | size
-
-
-[2 4 6 8] | skip 1
-[[editions]; [2015] [2018] [2021]] | skip 2
-
-
-[-2 0 2 -1] | skip until {|x| $x > 0 }
-let cond = {|x| $x > 0 }; [-2 0 2 -1] | skip until $cond
-[{a: -2} {a: 0} {a: 2} {a: -1}] | skip until {|x| $x.a > 0 }
-
-
-[-2 0 2 -1] | skip while {|x| $x < 0 }
-let cond = {|x| $x < 0 }; [-2 0 2 -1] | skip while $cond
-[{a: -2} {a: 0} {a: 2} {a: -1}] | skip while {|x| $x.a < 0 }
-
-
-sleep 1sec
-
-
-[2 0 1] | sort
-[2 0 1] | sort -r
-[betty amy sarah] | sort
-[betty amy sarah] | sort -r
-[airplane Truck Car] | sort -i
-[airplane Truck Car] | sort -i -r
-{b: 3, a: 4} | sort
-{b: 4, a: 3, c:1} | sort -v
-
-
-ls | sort-by modified
-ls | sort-by name -i
-[[fruit count]; [apple 9] [pear 3] [orange 7]] | sort-by fruit -r
-
-
-source foo.nu
-source ./foo.nu; say-hi
-
-
-source-env foo.nu
-
-
-
-
-'hello' | split chars
-'🇯🇵ほげ' | split chars -g
-
-
-'a--b--c' | split column '--'
-'abc' | split column -c ''
-['a-b' 'c-d'] | split column -
-['a - b' 'c - d'] | split column -r '\s*-\s*'
-
-
-[a, b, c, d, e, f, g] | split list d
-[[1,2], [2,3], [3,4]] | split list [2,3]
-[a, b, c, d, a, e, f, g] | split list a
-[a, b, c, d, a, e, f, g] | split list -r '(b|e)'
-
-
-'abc' | split row ''
-'a--b--c' | split row '--'
-'-a-b-c-' | split row '-'
-'a b c' | split row -r '\s+'
-
-
-'hello world' | split words
-'hello to the world' | split words -l 3
-http get https://www.gutenberg.org/files/11/11-0.txt | str downcase | split words -l 2 | uniq -c | sort-by count --reverse | first 10
-
-
-{
- '2019': [
- { name: 'andres', lang: 'rb', year: '2019' },
- { name: 'jt', lang: 'rs', year: '2019' }
- ],
- '2021': [
- { name: 'storm', lang: 'rs', 'year': '2021' }
- ]
- } | split-by lang
-
-
-start file.txt
-start file.jpg
-start .
-start file.pdf
-start https://www.nushell.sh
-
-
-
-
- 'NuShell' | str camel-case
-'this-is-the-first-case' | str camel-case
- 'this_is_the_second_case' | str camel-case
-[[lang, gems]; [nu_test, 100]] | str camel-case lang
-
-
-'good day' | str capitalize
-'anton' | str capitalize
-[[lang, gems]; [nu_test, 100]] | str capitalize lang
-
-
-
-
-'my_library.rb' | str contains '.rb'
-'my_library.rb' | str contains -i '.RB'
- [[ColA ColB]; [test 100]] | str contains 'e' ColA
- [[ColA ColB]; [test 100]] | str contains -i 'E' ColA
- [[ColA ColB]; [test hello]] | str contains 'e' ColA ColB
-'hello' | str contains 'banana'
-[one two three] | str contains o
-[one two three] | str contains -n o
-
-
-'nushell' | str distance 'nutshell'
-[{a: 'nutshell' b: 'numetal'}] | str distance 'nushell' 'a' 'b'
-
-
-'NU' | str downcase
-'TESTa' | str downcase
-[[ColA ColB]; [Test ABC]] | str downcase ColA
-[[ColA ColB]; [Test ABC]] | str downcase ColA ColB
-
-
-'my_library.rb' | str ends-with '.rb'
-'my_library.rb' | str ends-with '.txt'
-'my_library.rb' | str ends-with -i '.RB'
-
-
-
-
- 'my_library.rb' | str index-of '.rb'
-'🇯🇵ほげ ふが ぴよ' | str index-of -g 'ふが'
- '.rb.rb' | str index-of '.rb' -r 1..
- '123456' | str index-of '6' -r ..4
- '123456' | str index-of '3' -r 1..4
- '/this/is/some/path/file.txt' | str index-of '/' -e
-
-
-['nu', 'shell'] | str join
-['nu', 'shell'] | str join '-'
-
-
-'NuShell' | str kebab-case
-'thisIsTheFirstCase' | str kebab-case
-'THIS_IS_THE_SECOND_CASE' | str kebab-case
-[[lang, gems]; [nuTest, 100]] | str kebab-case lang
-
-
-'hello' | str length
-'🇯🇵ほげ ふが ぴよ' | str length -g
-['hi' 'there'] | str length
-
-
-
-
-'nu-shell' | str pascal-case
-'this-is-the-first-case' | str pascal-case
-'this_is_the_second_case' | str pascal-case
-[[lang, gems]; [nu_test, 100]] | str pascal-case lang
-
-
-'my_library.rb' | str replace '(.+).rb' '$1.nu'
-'abc abc abc' | str replace -a 'b' 'z'
-[[ColA ColB ColC]; [abc abc ads]] | str replace -a 'b' 'z' ColA ColC
-'dogs_$1_cats' | str replace '\$1' '$2' -n
-'c:\some\cool\path' | str replace 'c:\some\cool' '~' -s
-'abc abc abc' | str replace -a 'b' 'z' -s
-'a successful b' | str replace '\b([sS])uc(?:cs|s?)e(ed(?:ed|ing|s?)|ss(?:es|ful(?:ly)?|i(?:ons?|ve(?:ly)?)|ors?)?)\b' '${1}ucce$2'
-'GHIKK-9+*' | str replace '[*[:xdigit:]+]' 'z'
-
-
-'Nushell' | str reverse
-['Nushell' 'is' 'cool'] | str reverse
-
-
-
-
- "NuShell" | str screaming-snake-case
- "this_is_the_second_case" | str screaming-snake-case
-"this-is-the-first-case" | str screaming-snake-case
-[[lang, gems]; [nu_test, 100]] | str screaming-snake-case lang
-
-
- "NuShell" | str snake-case
- "this_is_the_second_case" | str snake-case
-"this-is-the-first-case" | str snake-case
-[[lang, gems]; [nuTest, 100]] | str snake-case lang
-
-
-'my_library.rb' | str starts-with 'my'
-'Cargo.toml' | str starts-with 'Car'
-'Cargo.toml' | str starts-with '.toml'
-'Cargo.toml' | str starts-with -i 'cargo'
-
-
- 'good nushell' | str substring 5..12
- '🇯🇵ほげ ふが ぴよ' | str substring -g 4..6
-
-
-'nu-shell' | str title-case
-'this is a test case' | str title-case
-[[title, count]; ['nu test', 100]] | str title-case title
-
-
-
-
-
-
-
-
-'Nu shell ' | str trim
-'=== Nu shell ===' | str trim -c '=' | str trim
-' Nu shell ' | str trim -l
-'=== Nu shell ===' | str trim -c '='
-' Nu shell ' | str trim -r
-'=== Nu shell ===' | str trim -r -c '='
-
-
-'nu' | str upcase
-
-
-sys
-(sys).host | get name
-(sys).host.name
-
-
-ls | table -n 1
-[[a b]; [1 2] [3 4]] | table
-[[a b]; [1 2] [2 [4 4]]] | table --expand
-[[a b]; [1 2] [2 [4 4]]] | table --collapse
-
-
-[1 2 3] | take 1
-[1 2 3] | take 2
-[[editions]; [2015] [2018] [2021]] | take 2
-0x[01 23 45] | take 2
-1..10 | take 3
-
-
-[-1 -2 9 1] | take until {|x| $x > 0 }
-let cond = {|x| $x > 0 }; [-1 -2 9 1] | take until $cond
-[{a: -1} {a: -2} {a: 9} {a: 1}] | take until {|x| $x.a > 0 }
-
-
-[-1 -2 9 1] | take while {|x| $x < 0 }
-let cond = {|x| $x < 0 }; [-1 -2 9 1] | take while $cond
-[{a: -1} {a: -2} {a: 9} {a: 1}] | take while {|x| $x.a < 0 }
-
-
-term size
-(term size).columns
-(term size).rows
-
-
-timeit { sleep 500ms }
-http get https://www.nushell.sh/book/ | timeit { split chars }
-timeit ls -la
-
-
-
-
-[[foo bar]; [1 2]] | to csv
-[[foo bar]; [1 2]] | to csv -s ';'
-{a: 1 b: 2} | to csv
-
-
-[[foo bar]; [1 2]] | to html
-[[foo bar]; [1 2]] | to html --partial
-[[foo bar]; [1 2]] | to html --dark
-
-
-[a b c] | to json
-[Joe Bob Sam] | to json -i 4
-[1 2 3] | to json -r
-
-
-[[foo bar]; [1 2]] | to md
-[[foo bar]; [1 2]] | to md --pretty
-[{"H1": "Welcome to Nushell" } [[foo bar]; [1 2]]] | to md --per-element --pretty
-[0 1 2] | to md --pretty
-
-
-[1 2 3] | to nuon
-[1 2 3] | to nuon --indent 2
-[1 2 3] | to nuon --indent 2 --raw
-{date: 2000-01-01, data: [1 [2 3] 4.56]} | to nuon --indent 2
-
-
-1 | to text
-git help -a | lines | find -r '^ ' | to text
-ls | to text
-
-
-{foo: 1 bar: 'qwe'} | to toml
-
-
-[[foo bar]; [1 2]] | to tsv
-{a: 1 b: 2} | to tsv
-
-
-{tag: note attributes: {} content : [{tag: remember attributes: {} content : [{tag: null attrs: null content : Event}]}]} | to xml
-{tag: note content : [{tag: remember content : [Event]}]} | to xml
-{tag: note content : [{tag: remember content : [Event]}]} | to xml -p 3
-
-
-[[foo bar]; ["1" "2"]] | to yaml
-
-
-touch fixture.json
-touch a b c
-touch -m fixture.json
-touch -m -d "yesterday" a b c
-touch -m -r fixture.json d e
-touch -a -d "August 24, 2019; 12:30:30" fixture.json
-
-
-[[c1 c2]; [1 2]] | transpose
-[[c1 c2]; [1 2]] | transpose key val
-[[c1 c2]; [1 2]] | transpose -i val
-{c1: 1, c2: 2} | transpose | transpose -i -r -d
-
-
-try { asdfasdf }
-try { asdfasdf } catch { echo 'missing' }
-
-
-tutor begin
-tutor -f "$in"
-
-
-[2 3 3 4] | uniq
-[1 2 2] | uniq -d
-[1 2 2] | uniq -u
-['hello' 'goodbye' 'Hello'] | uniq -i
-[1 2 2] | uniq -c
-
-
-[[fruit count]; [apple 9] [apple 2] [pear 3] [orange 7]] | uniq-by fruit
-
-
-{'name': 'nu', 'stars': 5} | update name 'Nushell'
-[[count fruit]; [1 'apple']] | enumerate | update item.count {|e| ($e.item.fruit | str length) + $e.index } | get item
-[[project, authors]; ['nu', ['Andrés', 'JT', 'Yehuda']]] | update authors {|row| $row.authors | str join ','}
-[[project, authors]; ['nu', ['Andrés', 'JT', 'Yehuda']]] | update authors {|| str join ','}
-
-
-[
- ["2021-04-16", "2021-06-10", "2021-09-18", "2021-10-15", "2021-11-16", "2021-11-17", "2021-11-18"];
- [ 37, 0, 0, 0, 37, 0, 0]
- ] | update cells { |value|
- if $value == 0 {
- ""
- } else {
- $value
- }
- }
-[
- ["2021-04-16", "2021-06-10", "2021-09-18", "2021-10-15", "2021-11-16", "2021-11-17", "2021-11-18"];
- [ 37, 0, 0, 0, 37, 0, 0]
- ] | update cells -c ["2021-11-18", "2021-11-17"] { |value|
- if $value == 0 {
- ""
- } else {
- $value
- }
- }
-
-
-{'name': 'nu', 'stars': 5} | upsert name 'Nushell'
-[[name lang]; [Nushell ''] [Reedline '']] | upsert lang 'Rust'
-{'name': 'nu', 'stars': 5} | upsert language 'Rust'
-[[count fruit]; [1 'apple']] | enumerate | upsert item.count {|e| ($e.item.fruit | str length) + $e.index } | get item
-[1 2 3] | upsert 0 2
-[1 2 3] | upsert 3 4
-
-
-
-
-{ mode:normal userid:31415 } | url build-query
-[[foo bar]; ["1" "2"]] | url build-query
-{a:"AT&T", b: "AT T"} | url build-query
-
-
-'https://example.com/foo bar' | url encode
-['https://example.com/foo bar' 'https://example.com/a>b' '中文字/eng/12 34'] | url encode
-'https://example.com/foo bar' | url encode --all
-
-
-{
- "scheme": "http",
- "username": "",
- "password": "",
- "host": "www.pixiv.net",
- "port": "",
- "path": "/member_illust.php",
- "query": "mode=medium&illust_id=99260204",
- "fragment": "",
- "params":
- {
- "mode": "medium",
- "illust_id": "99260204"
- }
- } | url join
-{
- "scheme": "http",
- "username": "user",
- "password": "pwd",
- "host": "www.pixiv.net",
- "port": "1234",
- "query": "test=a",
- "fragment": ""
- } | url join
-{
- "scheme": "http",
- "host": "www.pixiv.net",
- "port": "1234",
- "path": "user",
- "fragment": "frag"
- } | url join
-
-
-'http://user123:pass567@www.example.com:8081/foo/bar?param1=section&p2=&f[name]=vldc#hello' | url parse
-
-
-module spam { export def foo [] { "foo" } }; use spam foo; foo
-module foo { export def-env bar [] { let-env FOO_BAR = "BAZ" } }; use foo bar; bar; $env.FOO_BAR
-
-
-{ mode:normal userid:31415 } | values
-{ f:250 g:191 c:128 d:1024 e:2000 a:16 b:32 } | values
-[[name meaning]; [ls list] [mv move] [cd 'change directory']] | values
-
-
-version
-
-
-
-
-view files
-
-
-let abc = {|| echo 'hi' }; view source $abc
-def hi [] { echo 'Hi!' }; view source hi
-def-env foo [] { let-env BAR = 'BAZ' }; view source foo
-module mod-foo { export-env { let-env FOO_ENV = 'BAZ' } }; view source mod-foo
-alias hello = echo hi; view source hello
-
-
-some | pipeline | or | variable | debug -r; view span 1 2
-
-
-watch . --glob=**/*.rs {|| cargo test }
-watch . { |op, path, new_path| $"($op) ($path) ($new_path)"}
-watch /foo/bar { |op, path| $"($op) - ($path)(char nl)" | save --append changes_in_bar.log }
-
-
-[{a: 1} {a: 2}] | where a > 1
-[1 2] | where {|x| $x > 1}
-ls | where size > 2kb
-ls | where type == file
-ls | where name =~ "Car"
-ls | where modified >= (date now) - 2wk
-ls | where type == file | sort-by name -n | enumerate | where {|e| $e.item.name !~ $'^($e.index + 1)' } | each {|| get item }
-
-
-which myapp
-
-
-mut x = 0; while $x < 10 { $x = $x + 1 }
-
-
-[1 2 3 4] | window 2
-[1, 2, 3, 4, 5, 6, 7, 8] | window 2 --stride 3
-[1, 2, 3, 4, 5] | window 3 --stride 3 --remainder
-
-
-with-env [MYENV "my env value"] { $env.MYENV }
-with-env [X Y W Z] { $env.X }
-with-env [[X W]; [Y Z]] { $env.W }
-with-env {X: "Y", W: "Z"} { [$env.X $env.W] }
-
-
-[1 2 3] | wrap num
-1..3 | wrap num
-
-
-
-
-[1 2] | zip [3 4]
-1..3 | zip 4..6
-glob *.ogg | zip ['bang.ogg', 'fanfare.ogg', 'laser.ogg'] | each {|| mv $in.0 $in.1 }
-
-
diff --git a/benches/file-format-bench.rs b/benches/file-format-bench.rs
deleted file mode 100644
index c2e7765..0000000
--- a/benches/file-format-bench.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-use criterion::{criterion_group, criterion_main, Criterion};
-use nu_formatter::{config::Config, format_single_file};
-use std::path::PathBuf;
-
-fn criterion_benchmark(c: &mut Criterion) {
- c.bench_function("Format massive nu", |b| {
- b.iter(|| format_single_file(&PathBuf::from("./benches/example.nu"), &Config::default()));
- });
-}
-
-criterion_group!(benches, criterion_benchmark);
-criterion_main!(benches);
diff --git a/crates/nufmt/Cargo.toml b/crates/nufmt/Cargo.toml
new file mode 100644
index 0000000..34b15b6
--- /dev/null
+++ b/crates/nufmt/Cargo.toml
@@ -0,0 +1,19 @@
+[package]
+name = "nufmt"
+version = "0.1.0"
+edition = "2021"
+license = "MIT"
+authors = ["The NuShell Contributors"]
+description = "Formats nushell extremely fast"
+homepage = "https://github.com/nushell/nufmt"
+repository = "https://github.com/nushell/nufmt"
+readme = "README.md"
+keywords = ["nu", "nushell", "formatting", "cli"]
+categories = ["command-line-utilities"]
+
+[dependencies]
+env_logger = "0.10.0"
+log = "0.4.17"
+nu-parser = "0.81.0"
+nu-protocol = "0.81.0"
+
diff --git a/src/config.rs b/crates/nufmt/src/config.rs
similarity index 100%
rename from src/config.rs
rename to crates/nufmt/src/config.rs
diff --git a/src/formatting.rs b/crates/nufmt/src/format.rs
similarity index 82%
rename from src/formatting.rs
rename to crates/nufmt/src/format.rs
index 397446d..6590a1f 100644
--- a/src/formatting.rs
+++ b/crates/nufmt/src/format.rs
@@ -1,14 +1,9 @@
-//! In this module occurs most of the magic in `nufmt`.
-//!
-//! It has functions to format slice of bytes and some help functions to separate concerns while doing the job.
use crate::config::Config;
+use crate::utils::*;
+
use log::{info, trace};
use nu_parser::{flatten_block, parse, FlatShape};
-use nu_protocol::{
- ast::Block,
- engine::{self, StateWorkingSet},
- Span,
-};
+use nu_protocol::engine::{self, StateWorkingSet};
/// format an array of bytes
///
@@ -135,21 +130,3 @@ fn trim_ascii_whitespace(x: &[u8]) -> &[u8] {
let to = x.iter().rposition(|x| !x.is_ascii_whitespace()).unwrap();
&x[from..=to]
}
-
-/// return true if the Nushell block has at least 1 pipeline
-///
-/// This function exists because sometimes is passed to `nufmt` an empty String,
-/// or a nu code which the parser can't identify something runnable
-/// (like a list of comments)
-///
-/// We don't want to return a blank file if that is the case,
-/// so this check gives the opportunity to `nufmt`
-/// to know when not to touch the file at all in the implementation.
-fn block_has_pipelines(block: &Block) -> bool {
- !block.pipelines.is_empty()
-}
-
-/// return true if the given span is the last one
-fn is_last_span(span: Span, flat: &[(Span, FlatShape)]) -> bool {
- span == flat.last().unwrap().0
-}
diff --git a/crates/nufmt/src/lib.rs b/crates/nufmt/src/lib.rs
new file mode 100644
index 0000000..9ac95ec
--- /dev/null
+++ b/crates/nufmt/src/lib.rs
@@ -0,0 +1,61 @@
+use std::io::Write;
+use std::{fs::File, path::PathBuf};
+
+use log::{debug, error};
+use log::{info, trace};
+
+use config::Config;
+use format::{add_newline_at_end_of_file, format_inner};
+use utils::{is_file_extension, recurse_directory};
+
+/// format a Nushell file inplace
+pub fn format_file_inplace(file: &PathBuf, config: &Config) {
+ let contents = std::fs::read(file)
+ .unwrap_or_else(|_| panic!("something went wrong reading the file {}", file.display()));
+
+ let formatted_bytes = add_newline_at_end_of_file(format_inner(&contents, config));
+
+ if formatted_bytes == contents {
+ debug!("File is already formatted correctly.");
+ }
+
+ let mut writer = File::create(file).unwrap();
+ let file_bytes = formatted_bytes.as_slice();
+ writer
+ .write_all(file_bytes)
+ .expect("something went wrong writing");
+ trace!("written");
+}
+
+/// format a list of files, possibly one, and modify them inplace
+pub fn format_directory(files: Vec, options: &Config) {
+ for file in &files {
+ if !file.exists() {
+ error!("Error: {} not found!", file.to_str().unwrap());
+ } else if file.is_dir() {
+ for path in recurse_directory(file).unwrap() {
+ if is_file_extension(&path, ".nu") {
+ info!("formatting file: {:?}", &path);
+ format_file_inplace(&path, options);
+ } else {
+ info!("not nu file: skipping");
+ }
+ }
+ // Files only
+ } else {
+ info!("formatting file: {:?}", file);
+ format_file_inplace(file, options);
+ }
+ }
+}
+
+/// format a string of Nushell code
+pub fn format_string(input_string: &String, config: &Config) -> String {
+ let contents = input_string.as_bytes();
+ let formatted_bytes = format_inner(contents, config);
+ String::from_utf8(formatted_bytes).unwrap()
+}
+
+pub mod config;
+pub mod format;
+pub mod utils;
diff --git a/crates/nufmt/src/utils.rs b/crates/nufmt/src/utils.rs
new file mode 100644
index 0000000..15f54f8
--- /dev/null
+++ b/crates/nufmt/src/utils.rs
@@ -0,0 +1,52 @@
+use std::{
+ fs,
+ path::{Path, PathBuf},
+};
+
+use nu_parser::FlatShape;
+use nu_protocol::{ast::Block, Span};
+
+/// Check if the file matches the extension
+pub(crate) fn is_file_extension(file: &Path, extension: &str) -> bool {
+ String::from(file.to_str().unwrap()).ends_with(extension)
+}
+
+/// Walks down directory structure and returns all files
+pub(crate) fn recurse_directory(path: impl AsRef) -> std::io::Result> {
+ let mut buf = vec![];
+ let entries = fs::read_dir(path)?;
+
+ for entry in entries {
+ let entry = entry?;
+ let meta = entry.metadata()?;
+
+ if meta.is_dir() {
+ let mut subdir = recurse_directory(entry.path())?;
+ buf.append(&mut subdir);
+ }
+
+ if meta.is_file() {
+ buf.push(entry.path());
+ }
+ }
+
+ Ok(buf)
+}
+
+/// return true if the Nushell block has at least 1 pipeline
+///
+/// This function exists because sometimes is passed to `nufmt` an empty String,
+/// or a nu code which the parser can't identify something runnable
+/// (like a list of comments)
+///
+/// We don't want to return a blank file if that is the case,
+/// so this check gives the opportunity to `nufmt`
+/// to know when not to touch the file at all in the implementation.
+pub(crate) fn block_has_pipelines(block: &Block) -> bool {
+ !block.pipelines.is_empty()
+}
+
+/// return true if the given span is the last one
+pub(crate) fn is_last_span(span: Span, flat: &[(Span, FlatShape)]) -> bool {
+ span == flat.last().unwrap().0
+}
diff --git a/crates/nufmt_cli/Cargo.toml b/crates/nufmt_cli/Cargo.toml
new file mode 100644
index 0000000..94e5277
--- /dev/null
+++ b/crates/nufmt_cli/Cargo.toml
@@ -0,0 +1,12 @@
+[package]
+name = "nufmt_cli"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+nufmt = { path = "../nufmt" }
+clap = { version = "4.3.0", features = ["unicode", "derive"] }
+env_logger = "0.10.0"
+log = "0.4.17"
diff --git a/crates/nufmt_cli/src/main.rs b/crates/nufmt_cli/src/main.rs
new file mode 100644
index 0000000..e5c2a75
--- /dev/null
+++ b/crates/nufmt_cli/src/main.rs
@@ -0,0 +1,56 @@
+use clap::Parser;
+
+use log::trace;
+use std::{io::Write, path::PathBuf};
+
+use nufmt::{config::Config, format_directory, format_string};
+
+/// the CLI signature of the `nufmt` executable.
+#[derive(Parser)]
+#[command(author, version, about)]
+struct Cli {
+ #[arg(
+ required_unless_present("stdin"),
+ help = "one of more Nushell files you want to format"
+ )]
+ files: Vec,
+ #[arg(
+ short,
+ long,
+ conflicts_with = "files",
+ help = "a string of Nushell directly given to the formatter"
+ )]
+ stdin: Option,
+ #[arg(short, long, help = "the configuration file")]
+ config: Option,
+}
+
+fn main() {
+ env_logger::init();
+
+ let cli = Cli::parse();
+ trace!("recieved cli.files: {:?}", cli.files);
+ trace!("recieved cli.stdin: {:?}", cli.stdin);
+ trace!("recieved cli.config: {:?}", cli.config);
+
+ let cli_config = match cli.config {
+ None => Config::default(),
+ Some(input_cli) => {
+ todo!(
+ "cannot read from {:?} Reading a config from file not implemented!",
+ input_cli
+ )
+ }
+ };
+
+ match cli.files[..] {
+ [] => {
+ format_string(&cli.stdin.unwrap(), &cli_config);
+ }
+ _ => {
+ format_directory(cli.files, &cli_config);
+ }
+ };
+
+ std::io::stdout().flush().unwrap();
+}
diff --git a/docs/specification.md b/docs/specification.md
deleted file mode 100644
index d253844..0000000
--- a/docs/specification.md
+++ /dev/null
@@ -1,145 +0,0 @@
-# Specification
-
-This specification serves as a starting point to document how `nufmt` should work when formatting nushell scripts. It's meant to be very basic at this point, gradually covering more of the language features.
-
-## Supported Features
-
-### Indentation size
-
-There should be an `--indent` parameter to allow one to specify the number of spaces to use for indentation.
-
-### Indentation
-
-There should be a CRLF and indentation after open braces ()`{`). (TBD - Does this apply to other symbols like `[`, `(`, `|`, etc?)
-
-### Limit the characters per line
-
-There should be a `--limit` parameter to limit to the number of characters per line.
-
-### Number of empty lines before/after custom command
-
-There should be a `--lines-before` and `--lines-after` parameter to set the number of empty lines before and after a custom command.
-
-## Config file
-
-As `rustfmt` does it with a `TOML` file, `nufmt` could have a config file, alongside the command line flags above to set options in stone.
-We have identified the NUON format as a suitable data format for this project: after it's THE data format for `nushell`!
-
-With the values above, it could look something like:
-```nuon
-{
- CRLF: false,
- indent: 4,
- limit: 100,
- lines: {
- after: 1,
- before: 1
- }
-}
-```
-
-## Sensible (?) default and features
-
-- :one: do not always add newlines when it can help understand the central point of a command call
-```nushell
-http get ({
- scheme: https,
- host: api.github.com,
- path: /users/nushell/repos,
- params: {
- sort: updated,
- per_page: 100
- page: 1
- }
-} | url join)
-```
-to put the emphasis on the url structure
-> **Note**
-> the `({ ... } | url join)`
-
-- :two: put `|` at the start of the lines for readability, creating a "wall of pipes"
-```nushell
-def "apply to" [
- file: path
- modification: closure
-] {
- $file
- | path expand
- | open --raw
- | from toml
- | do $modification
- | save --force $file
-}
-```
-
-- :three: ternary-like conditions when conditions and the two branches are short
-```nushell
-let sign = if $value < 0 { -1 } else { 1 }
-```
-instead of
-```nushell
-let sign = (
- if $value < 0 {
- -1
- } else {
- 1
- }
-)
-```
-
-- :four: a newline before a block of comments
-```nushell
-some command
-
-# a comment to explain
-another comment
-
-# a block
-# of comment
-# for this
-last command
-```
-
-:five: two spaces before and one space after a comment on the same line as a command
-```nushell
-my-command # and some explaination
-```
-or in command arguments as well
-```nushell
-def foo [
- a: int # my integer argument
- b: string # my string integer
-] {}
-```
-
-- :six: 4 spaces as the default indentation
-
-- :seven: remove trailing whitespaces
-
-- :eight: single quotes for single characters and double quotes for strings => that behaviour might change with string interpolation and paths.
-> **Warning**
-> one should use single quotes (') or backticks (\`) to quote paths on Windows
-
-## Supported Commands
-
-This is the list of the supported commands and their idiomatic formatting. Indentation will be covered by the `--indent` flag but for these examples, 2 spaces will be used.
-
-### if
-
-```bash
-if condition {
- # some thing
-} else if {
- # some other thing
-} else {
- # else the last thing
-}
-```
-
-### for
-
-```bash
-for var in 0..100 {
- # do something here
-}
-```
diff --git a/scripts/update-nushell-version b/scripts/update-nushell-version
deleted file mode 100755
index 11dc8c2..0000000
--- a/scripts/update-nushell-version
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/env nu
-
-use std log
-
-def main [
- version: string # the new version of Nushell, e.g. 0.82.0
-] {
- log info "updating the badge in the README"
- open README.md
- | str replace 'https://img.shields.io/badge/nushell-v\d+\.\d+\.\d+-green' $"https://img.shields.io/badge/nushell-v($version)-green"
- | save --force README.md
-
- log info "updating the `nu-parser` dependency"
- cargo add $"nu-parser@($version)"
- log info "updating the `nu-protocol` dependency"
- cargo add $"nu-protocol@($version)"
-
- log warning "do not forget to commit and push this :wink:"
-}
diff --git a/src/lib.rs b/src/lib.rs
deleted file mode 100644
index 660f2f9..0000000
--- a/src/lib.rs
+++ /dev/null
@@ -1,133 +0,0 @@
-//! `nu_formatter` is a library for formatting nu.
-//!
-//! It does not do anything more than that, which makes it so fast.
-use config::Config;
-use formatting::{add_newline_at_end_of_file, format_inner};
-use log::{debug, trace};
-use std::fs::File;
-use std::io::Write;
-use std::path::PathBuf;
-
-pub mod config;
-mod formatting;
-
-/// format a Nushell file inplace
-pub fn format_single_file(file: &PathBuf, config: &Config) {
- let contents = std::fs::read(file)
- .unwrap_or_else(|_| panic!("something went wrong reading the file {}", file.display()));
-
- let formatted_bytes = add_newline_at_end_of_file(format_inner(&contents, config));
-
- if formatted_bytes == contents {
- debug!("File is already formatted correctly.");
- }
-
- let mut writer = File::create(file).unwrap();
- let file_bytes = formatted_bytes.as_slice();
- writer
- .write_all(file_bytes)
- .expect("something went wrong writing");
- trace!("written");
-}
-
-/// format a string of Nushell code
-pub fn format_string(input_string: &String, config: &Config) -> String {
- let contents = input_string.as_bytes();
- let formatted_bytes = format_inner(contents, config);
- String::from_utf8(formatted_bytes).unwrap()
-}
-
-#[cfg(test)]
-mod test {
- use super::*;
-
- /// test that
- /// 1. formatting the input gives the expected result
- /// 2. formatting the output of `nufmt` a second time does not change the content
- fn run_test(input: &str, expected: &str) {
- let formatted = format_string(&input.to_string(), &Config::default());
-
- assert_eq!(expected.to_string(), formatted);
- assert_eq!(formatted, format_string(&formatted, &Config::default()));
- }
-
- #[test]
- fn array_of_object() {
- let input = "[
- {
- \"a\": 0
- },
- {},
- {
- \"a\": null
- }
-]";
- let expected = "[{\"a\":0},{},{\"a\":null}]";
- run_test(input, expected);
- }
-
- #[test]
- fn echoes_primitive() {
- let input = "1.35";
- let expected = input;
- run_test(input, expected);
- }
-
- #[test]
- fn handle_escaped_strings() {
- let input = "\"hallo\\\"\"";
- let expected = input;
- run_test(input, expected);
- }
-
- #[test]
- fn ignore_comments() {
- let input = "# beginning of script comment
-
-let one = 1
-def my-func [
- param1:int # inline comment
-]{ print(param1)
-}
-myfunc(one)
-
-
-
-
-
-# final comment
-
-
-";
- let expected = "# beginning of script comment
-let one = 1
-def my-func [
- param1:int # inline comment
-]{ print(param1)
-}
-myfunc(one)
-# final comment";
- run_test(input, expected);
- }
-
- #[test]
- fn ignore_whitespace_in_string() {
- let input = "\" hallo \"";
- let expected = input;
- run_test(input, expected);
- }
-
- #[test]
- fn remove_additional_lines() {
- let input = "let one = 1\n\n\n";
- let expected = "let one = 1\n";
- run_test(input, expected);
- }
-
- #[test]
- fn remove_leading_whitespace() {
- let input = " 0";
- let expected = "0";
- run_test(input, expected);
- }
-}
diff --git a/src/main.rs b/src/main.rs
deleted file mode 100644
index fef3540..0000000
--- a/src/main.rs
+++ /dev/null
@@ -1,145 +0,0 @@
-#![doc = include_str!("../README.md")]
-
-use clap::Parser;
-use log::{error, info, trace};
-use nu_formatter::config::Config;
-use std::{
- fs,
- io::Write,
- path::{Path, PathBuf},
-};
-
-enum ExitCode {
- Success,
- Failure,
-}
-
-/// the CLI signature of the `nufmt` executable.
-#[derive(Parser)]
-#[command(author, version, about)]
-struct Cli {
- #[arg(
- required_unless_present("stdin"),
- help = "one of more Nushell files you want to format"
- )]
- files: Vec,
- #[arg(
- short,
- long,
- conflicts_with = "files",
- help = "a string of Nushell directly given to the formatter"
- )]
- stdin: Option,
- #[arg(short, long, help = "the configuration file")]
- config: Option,
-}
-
-fn exit_with_code(exit_code: ExitCode) {
- let code = match exit_code {
- ExitCode::Success => 0,
- ExitCode::Failure => 1,
- };
- trace!("exit code: {code}");
-
- // NOTE: this immediately terminates the process without doing any cleanup,
- // so make sure to finish all necessary cleanup before this is called.
- std::process::exit(code);
-}
-
-fn main() {
- env_logger::init();
-
- let cli = Cli::parse();
- trace!("recieved cli.files: {:?}", cli.files);
- trace!("recieved cli.stdin: {:?}", cli.stdin);
- trace!("recieved cli.config: {:?}", cli.config);
-
- let cli_config = match cli.config {
- None => Config::default(),
- Some(input_cli) => {
- todo!(
- "cannot read from {:?} Reading a config from file not implemented!",
- input_cli
- )
- }
- };
-
- let exit_code = match cli.files[..] {
- [] => format_string(cli.stdin, &cli_config),
- _ => format_files(cli.files, &cli_config),
- };
-
- std::io::stdout().flush().unwrap();
-
- exit_with_code(exit_code);
-}
-
-/// format a string passed via stdin and output it directly to stdout
-fn format_string(string: Option, options: &Config) -> ExitCode {
- let output = nu_formatter::format_string(&string.unwrap(), options);
- println!("output: \n{output}");
-
- ExitCode::Success
-}
-
-/// format a list of files, possibly one, and modify them inplace
-fn format_files(files: Vec, options: &Config) -> ExitCode {
- for file in &files {
- if !file.exists() {
- error!("Error: {} not found!", file.to_str().unwrap());
- return ExitCode::Failure;
- } else if file.is_dir() {
- for path in recurse_files(file).unwrap() {
- if is_file_extension(&path, ".nu") {
- info!("formatting file: {:?}", &path);
- nu_formatter::format_single_file(&path, options);
- } else {
- info!("not nu file: skipping");
- }
- }
- // Files only
- } else {
- info!("formatting file: {:?}", file);
- nu_formatter::format_single_file(file, options);
- }
- }
-
- ExitCode::Success
-}
-
-fn recurse_files(path: impl AsRef) -> std::io::Result> {
- let mut buf = vec![];
- let entries = fs::read_dir(path)?;
-
- for entry in entries {
- let entry = entry?;
- let meta = entry.metadata()?;
-
- if meta.is_dir() {
- let mut subdir = recurse_files(entry.path())?;
- buf.append(&mut subdir);
- }
-
- if meta.is_file() {
- buf.push(entry.path());
- }
- }
-
- Ok(buf)
-}
-
-/// Get the file extension
-fn is_file_extension(file: &Path, extension: &str) -> bool {
- String::from(file.to_str().unwrap()).ends_with(extension)
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
-
- #[test]
- fn clap_cli_construction() {
- use clap::CommandFactory;
- Cli::command().debug_assert();
- }
-}
diff --git a/toolkit.nu b/test.nu
similarity index 100%
rename from toolkit.nu
rename to test.nu