mirror of
https://github.com/nushell/nushell.git
synced 2025-06-19 17:38:14 +02: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,
|
span,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
cols.push("is_extern".to_string());
|
||||||
|
vals.push(Value::Bool {
|
||||||
|
val: decl.is_known_external(),
|
||||||
|
span,
|
||||||
|
});
|
||||||
|
|
||||||
cols.push("creates_scope".to_string());
|
cols.push("creates_scope".to_string());
|
||||||
vals.push(Value::Bool {
|
vals.push(Value::Bool {
|
||||||
val: signature.creates_scope,
|
val: signature.creates_scope,
|
||||||
|
@ -43,12 +43,12 @@ impl Default for Config {
|
|||||||
use_ls_colors: true,
|
use_ls_colors: true,
|
||||||
color_config: HashMap::new(),
|
color_config: HashMap::new(),
|
||||||
use_grid_icons: false,
|
use_grid_icons: false,
|
||||||
footer_mode: FooterMode::Never,
|
footer_mode: FooterMode::RowCount(25),
|
||||||
animate_prompt: ANIMATE_PROMPT_DEFAULT,
|
animate_prompt: ANIMATE_PROMPT_DEFAULT,
|
||||||
float_precision: 4,
|
float_precision: 4,
|
||||||
filesize_format: "auto".into(),
|
filesize_format: "auto".into(),
|
||||||
use_ansi_coloring: true,
|
use_ansi_coloring: true,
|
||||||
quick_completions: false,
|
quick_completions: true,
|
||||||
edit_mode: "emacs".into(),
|
edit_mode: "emacs".into(),
|
||||||
max_history_size: 1000,
|
max_history_size: 1000,
|
||||||
log_level: String::new(),
|
log_level: String::new(),
|
||||||
|
@ -256,6 +256,10 @@ pub enum ShellError {
|
|||||||
#[diagnostic(code(nu::shell::missing_config_value), url(docsrs))]
|
#[diagnostic(code(nu::shell::missing_config_value), url(docsrs))]
|
||||||
MissingConfigValue(String, #[label = "missing {0}"] Span),
|
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}")]
|
#[error("{0}")]
|
||||||
#[diagnostic()]
|
#[diagnostic()]
|
||||||
SpannedLabeledError(String, String, #[label("{1}")] Span),
|
SpannedLabeledError(String, String, #[label("{1}")] Span),
|
||||||
|
@ -96,21 +96,39 @@ impl FromValue for f64 {
|
|||||||
impl FromValue for Spanned<usize> {
|
impl FromValue for Spanned<usize> {
|
||||||
fn from_value(v: &Value) -> Result<Self, ShellError> {
|
fn from_value(v: &Value) -> Result<Self, ShellError> {
|
||||||
match v {
|
match v {
|
||||||
Value::Int { val, span } => Ok(Spanned {
|
Value::Int { val, span } => {
|
||||||
|
if val.is_negative() {
|
||||||
|
Err(ShellError::NeedsPositiveValue(*span))
|
||||||
|
} else {
|
||||||
|
Ok(Spanned {
|
||||||
item: *val as usize,
|
item: *val as usize,
|
||||||
span: *span,
|
span: *span,
|
||||||
}),
|
})
|
||||||
Value::Filesize { val, span } => Ok(Spanned {
|
}
|
||||||
|
}
|
||||||
|
Value::Filesize { val, span } => {
|
||||||
|
if val.is_negative() {
|
||||||
|
Err(ShellError::NeedsPositiveValue(*span))
|
||||||
|
} else {
|
||||||
|
Ok(Spanned {
|
||||||
item: *val as usize,
|
item: *val as usize,
|
||||||
span: *span,
|
span: *span,
|
||||||
}),
|
})
|
||||||
Value::Duration { val, span } => Ok(Spanned {
|
}
|
||||||
|
}
|
||||||
|
Value::Duration { val, span } => {
|
||||||
|
if val.is_negative() {
|
||||||
|
Err(ShellError::NeedsPositiveValue(*span))
|
||||||
|
} else {
|
||||||
|
Ok(Spanned {
|
||||||
item: *val as usize,
|
item: *val as usize,
|
||||||
span: *span,
|
span: *span,
|
||||||
}),
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
v => Err(ShellError::CantConvert(
|
v => Err(ShellError::CantConvert(
|
||||||
"integer".into(),
|
"non-negative integer".into(),
|
||||||
v.get_type().to_string(),
|
v.get_type().to_string(),
|
||||||
v.span()?,
|
v.span()?,
|
||||||
)),
|
)),
|
||||||
@ -121,12 +139,30 @@ impl FromValue for Spanned<usize> {
|
|||||||
impl FromValue for usize {
|
impl FromValue for usize {
|
||||||
fn from_value(v: &Value) -> Result<Self, ShellError> {
|
fn from_value(v: &Value) -> Result<Self, ShellError> {
|
||||||
match v {
|
match v {
|
||||||
Value::Int { val, .. } => Ok(*val as usize),
|
Value::Int { val, span } => {
|
||||||
Value::Filesize { val, .. } => Ok(*val as usize),
|
if val.is_negative() {
|
||||||
Value::Duration { val, .. } => Ok(*val as usize),
|
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(
|
v => Err(ShellError::CantConvert(
|
||||||
"integer".into(),
|
"non-negative integer".into(),
|
||||||
v.get_type().to_string(),
|
v.get_type().to_string(),
|
||||||
v.span()?,
|
v.span()?,
|
||||||
)),
|
)),
|
||||||
@ -203,12 +239,18 @@ impl FromValue for CellPath {
|
|||||||
span,
|
span,
|
||||||
}],
|
}],
|
||||||
}),
|
}),
|
||||||
Value::Int { val, .. } => Ok(CellPath {
|
Value::Int { val, span } => {
|
||||||
|
if val.is_negative() {
|
||||||
|
Err(ShellError::NeedsPositiveValue(*span))
|
||||||
|
} else {
|
||||||
|
Ok(CellPath {
|
||||||
members: vec![PathMember::Int {
|
members: vec![PathMember::Int {
|
||||||
val: *val as usize,
|
val: *val as usize,
|
||||||
span,
|
span: *span,
|
||||||
}],
|
}],
|
||||||
}),
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
x => Err(ShellError::CantConvert(
|
x => Err(ShellError::CantConvert(
|
||||||
"cell path".into(),
|
"cell path".into(),
|
||||||
x.get_type().to_string(),
|
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
|
## 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
|
## Parameters
|
||||||
|
|
||||||
@ -18,6 +18,7 @@ Post a body to a URL (HTTP POST operation).
|
|||||||
- `--password {any}`: the password when authenticating
|
- `--password {any}`: the password when authenticating
|
||||||
- `--content-type {any}`: the MIME type of content to post
|
- `--content-type {any}`: the MIME type of content to post
|
||||||
- `--content-length {any}`: the length of the content being posted
|
- `--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
|
- `--raw`: return values as a string instead of a table
|
||||||
- `--insecure`: allow insecure server connections when using SSL
|
- `--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 -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
|
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 = $"---
|
let top = $"---
|
||||||
title: ($command.command)
|
title: ($command.command)
|
||||||
layout: command
|
layout: command
|
||||||
@ -61,5 +61,6 @@ $"($example.description)
|
|||||||
|
|
||||||
let safe_name = ($command.command | str find-replace '\?' '' | str find-replace ' ' '_')
|
let safe_name = ($command.command | str find-replace '\?' '' | str find-replace ' ' '_')
|
||||||
$doc | save --raw $"./docs/commands/($safe_name).md"
|
$doc | save --raw $"./docs/commands/($safe_name).md"
|
||||||
|
$"./docs/commands/($safe_name).md"
|
||||||
} | length | $"($in) commands written"
|
} | length | $"($in) commands written"
|
||||||
|
|
||||||
|
@ -132,8 +132,8 @@ let $config = {
|
|||||||
cellpath: white
|
cellpath: white
|
||||||
}
|
}
|
||||||
use_grid_icons: $true
|
use_grid_icons: $true
|
||||||
footer_mode: always # always, never, number_of_rows, auto
|
footer_mode: "30" # always, never, number_of_rows, auto
|
||||||
quick_completions: $false # set this to $true to auto-select completions when only one remains
|
quick_completions: $true # set this to $false to prevent auto-selecting completions when only one remains
|
||||||
animate_prompt: $false # redraw the prompt every second
|
animate_prompt: $false # redraw the prompt every second
|
||||||
float_precision: 2
|
float_precision: 2
|
||||||
use_ansi_coloring: $true
|
use_ansi_coloring: $true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user