nushell/crates/nu-command/src
nibon7 a6da8ce769
Allow filesize type as a valid limit value (#11349)
# Description
This pr allow us to use `filesize` type as a valid limit value, which is
benefit for some file size based limits.

# User-Facing Changes
```console
/data/source/nushell> ulimit -f                                                                                                   
╭───┬─────────────────────────────────────────────────────┬───────────┬───────────╮
│ # │                     description                     │   soft    │   hard    │
├───┼─────────────────────────────────────────────────────┼───────────┼───────────┤
│ 0 │ Maximum size of files created by the shell (kB, -f) │ unlimited │ unlimited │
╰───┴─────────────────────────────────────────────────────┴───────────┴───────────╯
/data/source/nushell> ulimit -f 10Mib                                                                                           
/data/source/nushell> ulimit -f                                                                                                    
╭───┬─────────────────────────────────────────────────────┬───────┬───────╮
│ # │                     description                     │ soft  │ hard  │
├───┼─────────────────────────────────────────────────────┼───────┼───────┤
│ 0 │ Maximum size of files created by the shell (kB, -f) │ 10240 │ 10240 │
╰───┴─────────────────────────────────────────────────────┴───────┴───────╯
/data/source/nushell> ulimit -n                                                                                                 
╭───┬──────────────────────────────────────────────┬──────┬────────╮
│ # │                 description                  │ soft │  hard  │
├───┼──────────────────────────────────────────────┼──────┼────────┤
│ 0 │ Maximum number of open file descriptors (-n) │ 1024 │ 524288 │
╰───┴──────────────────────────────────────────────┴──────┴────────╯
/data/source/nushell> ulimit -n 10Mib                                                                                            
Error: nu:🐚:type_mismatch

  × Type mismatch.
   ╭─[entry #5:1:1]
 1 │ ulimit -n 10Mib
   ·             ─┬─
   ·              ╰── filesize is not compatible with resource RLIMIT_NOFILE
   ╰────
```

# Tests + Formatting
Make sure you've run and fixed any issues with these commands:

- [x] add `commands::ulimit::limit_set_filesize1`
- [x] add `commands::ulimit::limit_set_filesize2`
- [x] `cargo fmt --all -- --check` to check standard code formatting
(`cargo fmt --all` applies these changes)
- [x] `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used`
to check that you're using the standard code style
- [x] `cargo test --workspace` to check that all tests pass (on Windows
make sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- [x] `cargo run -- -c "use std testing; testing run-tests --path
crates/nu-std"` to run the tests for the standard library
2023-12-16 09:56:03 -06:00
..
bytes Enforce required, optional, and rest positional arguments start with an uppercase and end with a period. (#11285) 2023-12-15 14:32:37 +08:00
charting Enforce required, optional, and rest positional arguments start with an uppercase and end with a period. (#11285) 2023-12-15 14:32:37 +08:00
conversions Enforce required, optional, and rest positional arguments start with an uppercase and end with a period. (#11285) 2023-12-15 14:32:37 +08:00
database Enforce required, optional, and rest positional arguments start with an uppercase and end with a period. (#11285) 2023-12-15 14:32:37 +08:00
date Enforce required, optional, and rest positional arguments start with an uppercase and end with a period. (#11285) 2023-12-15 14:32:37 +08:00
debug Enforce required, optional, and rest positional arguments start with an uppercase and end with a period. (#11285) 2023-12-15 14:32:37 +08:00
env Enforce required, optional, and rest positional arguments start with an uppercase and end with a period. (#11285) 2023-12-15 14:32:37 +08:00
experimental Add functions for each Value case (#9736) 2023-07-21 08:20:33 -05:00
filesystem Enforce required, optional, and rest positional arguments start with an uppercase and end with a period. (#11285) 2023-12-15 14:32:37 +08:00
filters Enforce required, optional, and rest positional arguments start with an uppercase and end with a period. (#11285) 2023-12-15 14:32:37 +08:00
formats Convert remainder of ShellError variants to named fields (#11276) 2023-12-09 18:46:21 -06:00
generators Enforce required, optional, and rest positional arguments start with an uppercase and end with a period. (#11285) 2023-12-15 14:32:37 +08:00
hash Enforce required, optional, and rest positional arguments start with an uppercase and end with a period. (#11285) 2023-12-15 14:32:37 +08:00
help Enforce required, optional, and rest positional arguments start with an uppercase and end with a period. (#11285) 2023-12-15 14:32:37 +08:00
math Enforce required, optional, and rest positional arguments start with an uppercase and end with a period. (#11285) 2023-12-15 14:32:37 +08:00
misc Enforce required, optional, and rest positional arguments start with an uppercase and end with a period. (#11285) 2023-12-15 14:32:37 +08:00
network Enforce required, optional, and rest positional arguments start with an uppercase and end with a period. (#11285) 2023-12-15 14:32:37 +08:00
path Enforce required, optional, and rest positional arguments start with an uppercase and end with a period. (#11285) 2023-12-15 14:32:37 +08:00
platform Allow filesize type as a valid limit value (#11349) 2023-12-16 09:56:03 -06:00
random Enforce required, optional, and rest positional arguments start with an uppercase and end with a period. (#11285) 2023-12-15 14:32:37 +08:00
removed Enforce required, optional, and rest positional arguments start with an uppercase and end with a period. (#11285) 2023-12-15 14:32:37 +08:00
shells Enforce required, optional, and rest positional arguments start with an uppercase and end with a period. (#11285) 2023-12-15 14:32:37 +08:00
stor Move stor commands to category Database (#11315) 2023-12-13 16:24:16 +01:00
strings Add format meta command (#11334) 2023-12-15 14:57:18 +08:00
system Bubble up errors passed to complete (#11313) 2023-12-16 09:07:08 -06:00
viewers Convert Shellerror::GenericError to named fields (#11230) 2023-12-07 00:40:03 +01:00
default_context.rs Add ulimit command (#11324) 2023-12-15 07:11:17 -06:00
example_test.rs feat: Add unfold command (#10489) 2023-09-30 09:08:06 -05:00
lib.rs Add stor family of commands (#11170) 2023-11-29 08:02:46 -08:00
progress_bar.rs cp progress bar implementation (#8012) 2023-02-22 11:57:38 -08:00
sort_utils.rs Convert Shellerror::GenericError to named fields (#11230) 2023-12-07 00:40:03 +01:00