* Add possibility to declare optional parameters and switch flags
With this commit applied it is now possible to specify optional parameters and flags
as switches. This PR **only** makes guarantees about **parsing** optional flags and
switches correctly. This PR **does not guarantee flawless functionality** of
optional parameters / switches within scripts.
functionality within scripts. Example:
test.nu
```shell
def my_command [
opt_param?
opt_param2?: int
--switch
] {echo hi nushell}
```
```shell
> source test.nu
> my_command -h
───┬─────────
0 │ hi
1 │ nushell
───┴─────────
Usage:
> my_command <mandatory_param> (opt_param) (opt_param2) {flags}
Parameters:
<mandatory_param>
(opt_param)
(opt_param2)
Flags:
-h, --help: Display this help message
--switch
--opt_flag <any>
```
* Update def docs
* Display aliases and custom commands in which; Fix#2810
Example output of nu after the commit is applied:
```shell
/home/leo/repos/nushell(feature/which_inspect_alias)> def docker-ps [] { docker ps --format '{{json .}}' | from json -o }
/home/leo/repos/nushell(feature/which_inspect_alias)> which docker-ps
───┬───────────┬────────────────────────┬─────────
# │ arg │ path │ builtin
───┼───────────┼────────────────────────┼─────────
0 │ docker-ps │ nushell custom command │ No
───┴───────────┴────────────────────────┴─────────
/home/leo/repos/nushell(feature/which_inspect_alias)> alias d = gid pd
/home/leo/repos/nushell(feature/which_inspect_alias)> which d
───┬─────┬───────────────┬─────────
# │ arg │ path │ builtin
───┼─────┼───────────────┼─────────
0 │ d │ nushell alias │ No
───┴─────┴───────────────┴─────────
```
* Update documentation
* Begin allowing comments and multiline scripts.
* clippy
* Finish moving to groups. Test pass
* Keep going
* WIP
* WIP
* BROKEN WIP
* WIP
* WIP
* Fix more tests
* WIP: alias starts working
* Broken WIP
* Broken WIP
* Variables begin to work
* captures start working
* A little better but needs fixed scope
* Shorthand env setting
* Update main merge
* Broken WIP
* WIP
* custom command parsing
* Custom commands start working
* Fix coloring and parsing of block
* Almost there
* Add some tests
* Add more param types
* Bump version
* Fix benchmark
* Fix stuff
* Bump Rustyline to 7.0.0
* Append history instead of always save
* Add associated type to Hinter
* Convert to using Rustyline KeyEvent
* Use AcceptOrInsertLine as struct
* Cargo fmt
* Make convert_keyevent pub
* Better naming for RL conversion
* added math round
* added math floor
* added math ceil
* added math.md examples
* moved the detection of nonnumerical values in ceil/floor/round
* math round now works on streams
* math floor now works on streams
* math ceil now works on streams
* First draft for adding a `pretty` flag to `to md`
* rustfmt
* Fix Clippy warnings
* rustfmt
* Using Clippy suggestion broken code, reverting and putting in a statement to ignore clippy warning
* Add test for `to md -p`
* WIP - compiling but not working
* semi-working
* making progress
* working except for table lines
* fmt + clippy
* cleaned up some comments
* working line colors
* fmt, clippy, updated sample config.toml
* merges
* some info on how to set colors
* WIP - compiling but not working
* semi-working
* making progress
* working except for table lines
* fmt + clippy
* cleaned up some comments
* working line colors
* fmt, clippy, updated sample config.toml
* removed extra comments
* plugin changes to support script plugins
* all platforms can have plugins with file extensions
* added .cmd, .py, .ps1 for windows
* added more trace! statements to document request and response
* WIP
* pretty much working, need to figure out sink plugins
* added a home for scripting plugin examples, ran fmt
* Had a visit with my good friend Clippy. We're on speaking terms again.
* add viable plugin extensions
* clippy
* update to load plugins without extension in *nix/mac.
* fmt
* Add deserialization of Primitive::Duration; Fixes#2373
* Implement Sleep command
* Add comment saying you should name your rest field "rest"
* Fix typo
* Add documentation for sleep command
* Rename `calc` to `math eval` and allow it to optionally take the expression as an argument
* Moved calc tests to math eval
Also added 2 tests and changed 1 test
* Move calc docs to math eval
* Very rough idea
* Remove colour codes
* Work on command for generating docs
* Quick comment
* Use nested collapsible markdown
* Refine documentation command
* Clippy and rename docs
* This layout probably seems best
Also moved some code to documentation.rs to avoid making help.rs massive
* Delete summaries.md
* Add usage strings
* Remove static annotations
* get_documentation produces value
Which will be used like
'help generate_docs | save "something"'
The resulting yaml can be passed to a script for generating HTML/MD files in the website
* Fix subcommands
* DRY code
* Address clippy:
* Fix links
* Clippy lints
* Move documentation to more central location
* [ADD] Add draft documentation for autoview
* [ADD] Add draft documentation for pwd
* [ADD] Add draft documentation for touch
* [MOD] Improve description and add examples
Add the use of `textview` and `binaryview`.
Add examples for single value, source file and binary file.
* Add bool subcommand to random
* Fix function name copy paste error
* Fix issue 2062: allow deserialization of a decimal
* Add bias flag to `random bool`
* uniq: Add counting option (WIP!)
Usage:
fetch https://raw.githubusercontent.com/timbray/topfew/master/test/data/access-1k | lines | wrap item | uniq | sort-by count | last 10
* uniq: Add first test
* uniq: Re-enable the non-counting variant.
* uniq: Also handle primitive lines.
* uniq: Update documentation
* uniq: Final comment about error handling. Let's get some feedback
* uniq: Address review comments.
Not happy with the way I create a TypeError. There must be a cleaner
way. Anyway, good for shipping.
* uniq: Use Labeled_error as suggested by jturner in chat.
* uniq: Return error directly.
Co-authored-by: Christoph Siedentop <christoph@siedentop.name>
* Add math median example and unit tests
* Update output of other all math ls command examples to keep consistent with math median output
* Fix output of math max example
* Update output of other math commands using pwd examples to keep data consistent
* Move sum tests into math directory
* Move sum documentation over to math documentation
One sum example already existed in the math examples and a few of the others were outdated and didn't work, so I only moved one over, and updated their output
* Remove no-longer-in-use mod statement
* Add support to allow the week day start in cal to be configurable
* Fix variable name
* Use a flag instead of a configuration setting for specifying the starting day of the week
* Add 'every' command
* Add --skip option to 'every' command
This option skips instead of selects every nth row
* Fix descriptions for 'every' command
* Add docummentation for 'every' command
* Check actual filenames in 'every' command tests
* Adding math docs
* Add some comments to calculate
* Remove redudant message
Message already shows up in subcommands list
* Added not working example
Accidentantly
* Remove table
* Add `rm_always_trash` option to config
* Add `--permanent` flag to `rm`
* `rm`: error if both `-t` and `-p` are present
Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
* added examples and explanation to trim
inserted examples (taken from parse in cookbook) for lists and tables using trim
* Move `to-json` to `to json`
Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
* Adding iniitial draft for the addition of the count column on the histogram command
* Update histogram documentation
* Add count column test to histogram command
* Fix error in histogram documentation
* Don't include year and month by default, adds an option to display the quarters of the year
* Add a test for cal that checks that year requested is in the return
* rustfmt the cal tests
* Add cal command
* Fix docmentation to show commands on two lines
* Use bullet points on flag documentation for cal
* Dereference day before calling string method
* Silence Clippy warning regarding a function with too many arguments
* Update cal flag descriptions and documentation
* Add some tests for the cal command
This adds a top-level document for the new `to` command, with a list (of links) of all the subcommands.
All the to-* subcommands keep their filename, but the content is updated to use the new subcommand syntax.
Since not all subcommands have documentation, some items in the list are just text without a link. Also filled the list for the undocumented from* commands in the same style.
Fixes#1709
This adds a top-level document for the new `from` command, with a list of links of all the subcommands.
All the from-* subcommands keep their filename, but the content is updated to use the new subcommand syntax.
Needs matching update for to*
Ref #1709
* Detect built-in commands passed as args to `which`
This expands the built-in `which` command to detect nushell commands
that may have the same name as a binary in the path.
* Allow which to interpret multiple arguments
Previously, it would discard any argument besides the first. This allows
`which` to process multiple arguments. It also makes the output a stream
of rows.
* Use map to build the output
* Add boolean column for builtins
* Use macros for entry creation shortcuts
* Process command args and use async_stream
In order to use `ichwh`, I'll need to use async_stream. But in order to
avoid lifetime errors with that, I have to process the command args
before using them. I'll admit I don't fully understand what is going on
with the `args.process(...)` function, but it works.
* Use `ichwh` for path searching
This commit transitions from `which` to `ichwh`. The path search is now
done asynchronously.
* Enable the `--all` flag on `which`
* Make `which` respect external commands
Escaped commands passed to wich (e.g., `which "^ls"`), are now searched
before builtins.
* Fix clippy warnings
This commit resolves two warnings from clippy, in light of #1142.
* Update Cargo.lock to get new `ichwh` version
`ichwh@0.2.1` has support for local paths.
* Add documentation for command
* start playing with ways to use the uniq command
* WIP
* Got uniq working, but still need to figure out args issue and add tests
* Add some tests for uniq
* fmt
* remove commented out code
* Add documentation and some additional tests showing uniq values and rows. Also removed args TODO
* add changes that didn't get committed
* whoops, I didn't save the docs correctly...
* fmt
* Add a test for uniq with nested json
* Add another test
* Fix unique-ness when json keys are out of order and make the test json more complicated
fixes#969, admittedly without a --delimiter alias
moves from_structured_data.rs to from_delimited_data.rs to better
identify its scope and adds to_delimited_data.rs. Now csv and tsv both
use the same code, tsv passes in a fixed '\t' argument where csv passes
in the value of --separator
Adds new substr function to str plugin with tests and documentation
Function takes a start/end location as a string in the form "##,##", both sides of comma are optional, and
behaves like Rust's own index operator [##..##].