From fbb65cde44891c1c90d6dfa7207577bba5f0adca Mon Sep 17 00:00:00 2001 From: Sebastian Jung Date: Fri, 29 Nov 2019 18:15:51 +0100 Subject: [PATCH 1/7] add documentation for save, config --- docs/commands/config.md | 43 ++++++++++++++++++++++++++++++++++++++ docs/commands/from-yaml.md | 2 +- docs/commands/save.md | 28 +++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 docs/commands/config.md create mode 100644 docs/commands/save.md diff --git a/docs/commands/config.md b/docs/commands/config.md new file mode 100644 index 0000000000..f5605e23a8 --- /dev/null +++ b/docs/commands/config.md @@ -0,0 +1,43 @@ +# config + +Configuration management. + +Syntax: `config {flags}` + +### Flags + + + --load + load the config from the path give + + --set + set a value in the config, eg) --set [key value] + + --set_into + sets a variable from values in the pipeline + + --get + get a value from the config + + --remove + remove a value from the config + + --clear + clear the config + + --path + return the path to the config file + +### Variables + +| Variable | Type | Description | +| ------------- | ------------- | ----- | +| path | table of strings | PATH to use to find binaries | +| env | row | the environment variables to pass to external commands | +| ctrlc_exit | boolean | whether or not to exit Nu after multiple ctrl-c presses | +| table_mode | "light" or other | enable lightweight or normal tables | +| edit_mode | "vi" or "emacs" | changes line editing to "vi" or "emacs" mode | + +## Examples + +A more detailed description on how to use this command to configure Nu shell can be found in the configuration chapter of [Nu Book](https://book.nushell.sh/). \ No newline at end of file diff --git a/docs/commands/from-yaml.md b/docs/commands/from-yaml.md index 1c81c7dc94..90a2dd90ac 100644 --- a/docs/commands/from-yaml.md +++ b/docs/commands/from-yaml.md @@ -1,6 +1,6 @@ # from-yaml -Parse text as `.yaml/.yml` and create table. +Parse text as `.yaml/.yml` and create table. Use this when nushell cannot dertermine the input file extension. Syntax: `from-yaml` diff --git a/docs/commands/save.md b/docs/commands/save.md new file mode 100644 index 0000000000..2ff76f5370 --- /dev/null +++ b/docs/commands/save.md @@ -0,0 +1,28 @@ +# save + +This command saves the contents of the pipeline to a file. Use this in combination with the `to-json`, `to-csv`, ... commands to save the contents in the specified format. + +Syntax: `save (path) {flags}` + +### Parameters: + +* `(path)` the path to save contents to + +### Flags + + --raw + treat values as-is rather than auto-converting based on file extension + +## Example + +You can save the name of files in a directory like this: + +```shell +> ls | where type == File | pick name | save +``` + +Or you can format it in supported formats using one of the `to-*` commands: + +```shell +> ls | where type == File | pick name | to-csv | save +``` \ No newline at end of file From d40aea5d0a4e6795093a1649078d66210fe6f2b6 Mon Sep 17 00:00:00 2001 From: Sebastian Jung Date: Sat, 30 Nov 2019 12:48:23 +0100 Subject: [PATCH 2/7] add documentation for get, ps --- docs/commands/get.md | 54 ++++++++++++++++++++++++++++++++++++++++++++ docs/commands/ps.md | 25 ++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 docs/commands/get.md create mode 100644 docs/commands/ps.md diff --git a/docs/commands/get.md b/docs/commands/get.md new file mode 100644 index 0000000000..5ab472130d --- /dev/null +++ b/docs/commands/get.md @@ -0,0 +1,54 @@ +# get + +Open given cells as text. + +Syntax: `get ...args` + +### Parameters: + +* `args`: optionally return additional data by path + +## Examples + +If we run `sys` we recieve a table which contains tables itself: + +```shell +> sys +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━ + host │ cpu │ disks │ mem │ temp │ net │ battery +────────────────────────────────────────┼────────────────────────────────────┼────────────────┼───────────────────────────────────────┼────────────────┼────────────────┼──────────────── + [row arch hostname name release uptime │ [row cores current ghz max ghz min │ [table 7 rows] │ [row free swap free swap total total] │ [table 6 rows] │ [table 3 rows] │ [table 1 rows] + users] │ ghz] │ │ │ │ │ +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━ +``` + +To access one of the embeded tables we can use the `get` command + +```shell +> sys | get cpu +━━━━━━━┯━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━ + cores │ current ghz │ min ghz │ max ghz +───────┼───────────────────┼────────────────────┼─────────────────── + 4 │ 1.530000000000000 │ 0.5000000000000000 │ 3.500000000000000 +━━━━━━━┷━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━ +``` +```shell +> sys | get battery +━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━ + vendor │ model │ mins to full +────────┼──────────┼────────────────── + SMP │ L14M2P21 │ 16.7024000000000 +━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━ +``` + +There's also the ability to pass multiple parameters to `get` which results in an output like this + +```shell +sys | get cpu battery +━━━┯━━━━━━━┯━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━ + # │ cores │ current ghz │ min ghz │ max ghz │ vendor │ model │ mins to full +───┼───────┼───────────────────┼────────────────────┼───────────────────┼────────┼──────────┼─────────────────── + 0 │ 4 │ 1.500000000000000 │ 0.5000000000000000 │ 3.500000000000000 │ │ │ + 1 │ │ │ │ │ SMP │ L14M2P21 │ 16.94503000000000 +━━━┷━━━━━━━┷━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━ +``` \ No newline at end of file diff --git a/docs/commands/ps.md b/docs/commands/ps.md new file mode 100644 index 0000000000..abf0b0714d --- /dev/null +++ b/docs/commands/ps.md @@ -0,0 +1,25 @@ +# ps + +This command shows information about system processes. + +Syntax: `ps` + +## Example + +```shell +> ps +... +━━━━┯━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━ + # │ pid │ name │ status │ cpu +────┼───────┼────────────────────────────────────────────────────────────────────┼─────────┼─────────────────── + 50 │ 10184 │ firefox.exe │ Running │ 0.000000000000000 + 51 │ 11584 │ WindowsTerminal.exe │ Running │ 0.000000000000000 + 52 │ 11052 │ conhost.exe │ Running │ 0.000000000000000 + 53 │ 7076 │ nu.exe │ Running │ 0.000000000000000 + ... + 66 │ 3000 │ Code.exe │ Running │ 0.000000000000000 + 67 │ 5388 │ conhost.exe │ Running │ 0.000000000000000 + 68 │ 6268 │ firefox.exe │ Running │ 0.000000000000000 + 69 │ 8972 │ nu_plugin_ps.exe │ Running │ 58.00986000000000 +━━━━┷━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━ +``` \ No newline at end of file From e38a4323b4874b45f2945c1ae04869207f110209 Mon Sep 17 00:00:00 2001 From: Sebastian Jung Date: Sat, 30 Nov 2019 13:38:52 +0100 Subject: [PATCH 3/7] add documentation for from-tsv, from-xml --- docs/commands/from-tsv.md | 52 +++++++++++++++++++++++++++++++++++++++ docs/commands/from-xml.md | 34 +++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 docs/commands/from-tsv.md create mode 100644 docs/commands/from-xml.md diff --git a/docs/commands/from-tsv.md b/docs/commands/from-tsv.md new file mode 100644 index 0000000000..86452de97a --- /dev/null +++ b/docs/commands/from-tsv.md @@ -0,0 +1,52 @@ +# from-tsv + +Parse text as `.tsv` and create table. + +Syntax: `from-tsv {flags}` + +### Flags: + + --headerless + don't treat the first row as column names + +## Examples + +Let's say we have the following file which is formatted like a `tsv` file: + +```shell +> open elements.txt +Symbol Element +H Hydrogen +He Helium +Li Lithium +Be Beryllium +``` + +If we pass the output of the `open` command to `from-tsv` we get a correct formatted table: + +```shell +> open elements.txt | from-tsv +━━━┯━━━━━━━━┯━━━━━━━━━━━ + # │ Symbol │ Element +───┼────────┼─────────── + 0 │ H │ Hydrogen + 1 │ He │ Helium + 2 │ Li │ Lithium + 3 │ Be │ Beryllium +━━━┷━━━━━━━━┷━━━━━━━━━━━ +``` + +Using the `--headerless` flag has the following output: + +```shell +> open elements.txt | from-tsv --headerless +━━━━┯━━━━━━━━━┯━━━━━━━━━━━ + # │ Column1 │ Column2 +────┼─────────┼─────────── + 0 │ Symbol │ Element + 1 │ H │ Hydrogen + 2 │ He │ Helium + 3 │ Li │ Lithium + 4 │ Be │ Beryllium +━━━━┷━━━━━━━━━┷━━━━━━━━━━━ +``` \ No newline at end of file diff --git a/docs/commands/from-xml.md b/docs/commands/from-xml.md new file mode 100644 index 0000000000..d7a9e2a78d --- /dev/null +++ b/docs/commands/from-xml.md @@ -0,0 +1,34 @@ +# from-xml + +Parse text as `.xml` and create table. Use this when nushell cannot dertermine the input file extension. + +Syntax: `from-xml` + +## Examples + +Let's say we've got a file in `xml` format but the file extension is different so Nu can't auto-format it: + +```shell +> open world.txt + + + Africa + Antarctica + Asia + Australia + Europe + North America + South America + +``` + +We can use `from-xml` to read the input like a `xml` file: + +```shell +> open world.txt | from-xml +━━━━━━━━━━━━━━━━ + world +──────────────── + [table 7 rows] +━━━━━━━━━━━━━━━━ +``` \ No newline at end of file From c63ad610f50205db759a924163abbc6f2c8dcd51 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sun, 1 Dec 2019 06:59:53 +1300 Subject: [PATCH 4/7] Update config.md --- docs/commands/config.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/commands/config.md b/docs/commands/config.md index f5605e23a8..cae8e43ef3 100644 --- a/docs/commands/config.md +++ b/docs/commands/config.md @@ -40,4 +40,8 @@ Syntax: `config {flags}` ## Examples -A more detailed description on how to use this command to configure Nu shell can be found in the configuration chapter of [Nu Book](https://book.nushell.sh/). \ No newline at end of file +```shell +> config --set [table_mode "light"] +``` + +A more detailed description on how to use this command to configure Nu shell can be found in the configuration chapter of [Nu Book](https://book.nushell.sh/en/configuration). From 6bfb4207c4331ab9a5aa5ea10d5c27b93e3a4de6 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Sun, 1 Dec 2019 07:00:36 +1300 Subject: [PATCH 5/7] Update from-yaml.md --- docs/commands/from-yaml.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/commands/from-yaml.md b/docs/commands/from-yaml.md index 90a2dd90ac..1c7e9fef78 100644 --- a/docs/commands/from-yaml.md +++ b/docs/commands/from-yaml.md @@ -1,6 +1,6 @@ # from-yaml -Parse text as `.yaml/.yml` and create table. Use this when nushell cannot dertermine the input file extension. +Parse text as `.yaml/.yml` and create table. Use this when nushell cannot determine the input file extension. Syntax: `from-yaml` From 9bd25d7427e9f964828e45972e95e7139306e199 Mon Sep 17 00:00:00 2001 From: Sebastian Jung Date: Sat, 30 Nov 2019 21:07:43 +0100 Subject: [PATCH 6/7] fix error in save.md --- docs/commands/save.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/commands/save.md b/docs/commands/save.md index 2ff76f5370..fe1ce66efa 100644 --- a/docs/commands/save.md +++ b/docs/commands/save.md @@ -18,11 +18,13 @@ Syntax: `save (path) {flags}` You can save the name of files in a directory like this: ```shell -> ls | where type == File | pick name | save +> ls | where type == File | pick name | save filenames.csv ``` Or you can format it in supported formats using one of the `to-*` commands: ```shell -> ls | where type == File | pick name | to-csv | save -``` \ No newline at end of file +> ls | where type == File | pick name | to-csv | save filenames +``` + +`filename.csv` and `filenames` are both `csv` formatted files. Nu auto-converts the format if a supported file extension is given. \ No newline at end of file From 11ff8190b1e247c399178b4b1ebe49b72e27b299 Mon Sep 17 00:00:00 2001 From: Sebastian Jung Date: Sat, 30 Nov 2019 21:15:12 +0100 Subject: [PATCH 7/7] add documentation for format --- docs/commands/format.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 docs/commands/format.md diff --git a/docs/commands/format.md b/docs/commands/format.md new file mode 100644 index 0000000000..836f25b98a --- /dev/null +++ b/docs/commands/format.md @@ -0,0 +1,37 @@ +# format + +Format columns into a string using a simple pattern + +Syntax: `format ` + +### Parameters + +* ``: the pattern to match + +## Example + +Let's say we have a table like this: + +```shell +> open pets.csv +━━━┯━━━━━━━━━━━┯━━━━━━━━┯━━━━━ + # │ animal │ name │ age +───┼───────────┼────────┼───── + 0 │ cat │ Tom │ 7 + 1 │ dog │ Alfred │ 10 + 2 │ chameleon │ Linda │ 1 +━━━┷━━━━━━━━━━━┷━━━━━━━━┷━━━━━ +``` + +`format` allows us to convert table data into a string by following a formatting pattern. To print the value of a column we have to put the column name in curly brackets: + +```shell +> open pets.csv | format "{name} is a {age} year old {animal}" +━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + # │ +───┼───────────────────────────────── + 0 │ Tom is a 7 year old cat + 1 │ Alfred is a 10 year old dog + 2 │ Linda is a 1 year old chameleon +━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +``` \ No newline at end of file