mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 16:33:37 +01:00
A few fixes to docs generation and default config (#4570)
* A few fixes to docs generation and default config * A few more fixes
This commit is contained in:
parent
6024a17a5b
commit
2ba12afb01
@ -937,6 +937,12 @@ pub fn eval_variable(
|
||||
span,
|
||||
});
|
||||
|
||||
cols.push("is_extern".to_string());
|
||||
vals.push(Value::Bool {
|
||||
val: decl.is_known_external(),
|
||||
span,
|
||||
});
|
||||
|
||||
cols.push("creates_scope".to_string());
|
||||
vals.push(Value::Bool {
|
||||
val: signature.creates_scope,
|
||||
|
@ -43,12 +43,12 @@ impl Default for Config {
|
||||
use_ls_colors: true,
|
||||
color_config: HashMap::new(),
|
||||
use_grid_icons: false,
|
||||
footer_mode: FooterMode::Never,
|
||||
footer_mode: FooterMode::RowCount(25),
|
||||
animate_prompt: ANIMATE_PROMPT_DEFAULT,
|
||||
float_precision: 4,
|
||||
filesize_format: "auto".into(),
|
||||
use_ansi_coloring: true,
|
||||
quick_completions: false,
|
||||
quick_completions: true,
|
||||
edit_mode: "emacs".into(),
|
||||
max_history_size: 1000,
|
||||
log_level: String::new(),
|
||||
|
@ -256,6 +256,10 @@ pub enum ShellError {
|
||||
#[diagnostic(code(nu::shell::missing_config_value), url(docsrs))]
|
||||
MissingConfigValue(String, #[label = "missing {0}"] Span),
|
||||
|
||||
#[error("Negative value passed when positive one is required")]
|
||||
#[diagnostic(code(nu::shell::needs_positive_value), url(docsrs))]
|
||||
NeedsPositiveValue(#[label = "use a positive value"] Span),
|
||||
|
||||
#[error("{0}")]
|
||||
#[diagnostic()]
|
||||
SpannedLabeledError(String, String, #[label("{1}")] Span),
|
||||
|
@ -96,21 +96,39 @@ impl FromValue for f64 {
|
||||
impl FromValue for Spanned<usize> {
|
||||
fn from_value(v: &Value) -> Result<Self, ShellError> {
|
||||
match v {
|
||||
Value::Int { val, span } => Ok(Spanned {
|
||||
item: *val as usize,
|
||||
span: *span,
|
||||
}),
|
||||
Value::Filesize { val, span } => Ok(Spanned {
|
||||
item: *val as usize,
|
||||
span: *span,
|
||||
}),
|
||||
Value::Duration { val, span } => Ok(Spanned {
|
||||
item: *val as usize,
|
||||
span: *span,
|
||||
}),
|
||||
Value::Int { val, span } => {
|
||||
if val.is_negative() {
|
||||
Err(ShellError::NeedsPositiveValue(*span))
|
||||
} else {
|
||||
Ok(Spanned {
|
||||
item: *val as usize,
|
||||
span: *span,
|
||||
})
|
||||
}
|
||||
}
|
||||
Value::Filesize { val, span } => {
|
||||
if val.is_negative() {
|
||||
Err(ShellError::NeedsPositiveValue(*span))
|
||||
} else {
|
||||
Ok(Spanned {
|
||||
item: *val as usize,
|
||||
span: *span,
|
||||
})
|
||||
}
|
||||
}
|
||||
Value::Duration { val, span } => {
|
||||
if val.is_negative() {
|
||||
Err(ShellError::NeedsPositiveValue(*span))
|
||||
} else {
|
||||
Ok(Spanned {
|
||||
item: *val as usize,
|
||||
span: *span,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
v => Err(ShellError::CantConvert(
|
||||
"integer".into(),
|
||||
"non-negative integer".into(),
|
||||
v.get_type().to_string(),
|
||||
v.span()?,
|
||||
)),
|
||||
@ -121,12 +139,30 @@ impl FromValue for Spanned<usize> {
|
||||
impl FromValue for usize {
|
||||
fn from_value(v: &Value) -> Result<Self, ShellError> {
|
||||
match v {
|
||||
Value::Int { val, .. } => Ok(*val as usize),
|
||||
Value::Filesize { val, .. } => Ok(*val as usize),
|
||||
Value::Duration { val, .. } => Ok(*val as usize),
|
||||
Value::Int { val, span } => {
|
||||
if val.is_negative() {
|
||||
Err(ShellError::NeedsPositiveValue(*span))
|
||||
} else {
|
||||
Ok(*val as usize)
|
||||
}
|
||||
}
|
||||
Value::Filesize { val, span } => {
|
||||
if val.is_negative() {
|
||||
Err(ShellError::NeedsPositiveValue(*span))
|
||||
} else {
|
||||
Ok(*val as usize)
|
||||
}
|
||||
}
|
||||
Value::Duration { val, span } => {
|
||||
if val.is_negative() {
|
||||
Err(ShellError::NeedsPositiveValue(*span))
|
||||
} else {
|
||||
Ok(*val as usize)
|
||||
}
|
||||
}
|
||||
|
||||
v => Err(ShellError::CantConvert(
|
||||
"integer".into(),
|
||||
"non-negative integer".into(),
|
||||
v.get_type().to_string(),
|
||||
v.span()?,
|
||||
)),
|
||||
@ -203,12 +239,18 @@ impl FromValue for CellPath {
|
||||
span,
|
||||
}],
|
||||
}),
|
||||
Value::Int { val, .. } => Ok(CellPath {
|
||||
members: vec![PathMember::Int {
|
||||
val: *val as usize,
|
||||
span,
|
||||
}],
|
||||
}),
|
||||
Value::Int { val, span } => {
|
||||
if val.is_negative() {
|
||||
Err(ShellError::NeedsPositiveValue(*span))
|
||||
} else {
|
||||
Ok(CellPath {
|
||||
members: vec![PathMember::Int {
|
||||
val: *val as usize,
|
||||
span: *span,
|
||||
}],
|
||||
})
|
||||
}
|
||||
}
|
||||
x => Err(ShellError::CantConvert(
|
||||
"cell path".into(),
|
||||
x.get_type().to_string(),
|
||||
|
@ -1,16 +0,0 @@
|
||||
---
|
||||
title: git checkout
|
||||
layout: command
|
||||
version: 0.59.0
|
||||
---
|
||||
|
||||
|
||||
|
||||
## Signature
|
||||
|
||||
```> git checkout (branch)```
|
||||
|
||||
## Parameters
|
||||
|
||||
- `branch`:
|
||||
|
@ -1,17 +0,0 @@
|
||||
---
|
||||
title: git push
|
||||
layout: command
|
||||
version: 0.59.0
|
||||
---
|
||||
|
||||
|
||||
|
||||
## Signature
|
||||
|
||||
```> git push (remote) (branch)```
|
||||
|
||||
## Parameters
|
||||
|
||||
- `remote`:
|
||||
- `branch`:
|
||||
|
@ -8,7 +8,7 @@ Post a body to a URL (HTTP POST operation).
|
||||
|
||||
## Signature
|
||||
|
||||
```> post (path) (body) --user --password --content-type --content-length --raw --insecure```
|
||||
```> post (path) (body) --user --password --content-type --content-length --headers --raw --insecure```
|
||||
|
||||
## Parameters
|
||||
|
||||
@ -18,6 +18,7 @@ Post a body to a URL (HTTP POST operation).
|
||||
- `--password {any}`: the password when authenticating
|
||||
- `--content-type {any}`: the MIME type of content to post
|
||||
- `--content-length {any}`: the length of the content being posted
|
||||
- `--headers {any}`: custom headers you want to add
|
||||
- `--raw`: return values as a string instead of a table
|
||||
- `--insecure`: allow insecure server connections when using SSL
|
||||
|
||||
@ -33,3 +34,8 @@ Post content to url.com, with username and password
|
||||
> post -u myuser -p mypass url.com 'body'
|
||||
```
|
||||
|
||||
Post content to url.com, with custom header
|
||||
```shell
|
||||
> post -H [my-header-key my-header-value] url.com
|
||||
```
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
let vers = (version).version
|
||||
|
||||
for command in ($scope.commands | where is_custom == $false) {
|
||||
for command in ($scope.commands | where is_custom == $false && is_external == $false) {
|
||||
let top = $"---
|
||||
title: ($command.command)
|
||||
layout: command
|
||||
@ -61,5 +61,6 @@ $"($example.description)
|
||||
|
||||
let safe_name = ($command.command | str find-replace '\?' '' | str find-replace ' ' '_')
|
||||
$doc | save --raw $"./docs/commands/($safe_name).md"
|
||||
$"./docs/commands/($safe_name).md"
|
||||
} | length | $"($in) commands written"
|
||||
|
||||
|
@ -132,8 +132,8 @@ let $config = {
|
||||
cellpath: white
|
||||
}
|
||||
use_grid_icons: $true
|
||||
footer_mode: always # always, never, number_of_rows, auto
|
||||
quick_completions: $false # set this to $true to auto-select completions when only one remains
|
||||
footer_mode: "30" # always, never, number_of_rows, auto
|
||||
quick_completions: $true # set this to $false to prevent auto-selecting completions when only one remains
|
||||
animate_prompt: $false # redraw the prompt every second
|
||||
float_precision: 2
|
||||
use_ansi_coloring: $true
|
||||
|
Loading…
Reference in New Issue
Block a user