mirror of
https://github.com/nushell/nushell.git
synced 2025-08-14 01:18:29 +02:00
Further cleanup of Span::test_data
usage + span fixes (#7595)
# Description Inspired by #7592 For brevity use `Value::test_{string,int,float,bool}` Includes fixes to commands that were abusing `Span::test_data` in their implementation. Now the call span is used where possible or the explicit `Span::unknonw` is used. ## Command fixes - Fix abuse of `Span::test_data()` in `query_xml` - Fix abuse of `Span::test_data()` in `term size` - Fix abuse of `Span::test_data()` in `seq date` - Fix two abuses of `Span::test_data` in `nu-cli` - Change `Span::test_data` to `Span::unknown` in `keybindings listen` - Add proper call span to `registry query` - Fix span use in `nu_plugin_query` - Fix span assignment in `select` - Use `Span::unknown` instead of `test_data` in more places ## Other - Use `Value::test_int`/`test_float()` consistently - More `test_string` and `test_bool` - Fix unused imports # User-Facing Changes Some commands may now provide more helpful spans for downstream use in errors
This commit is contained in:
committed by
GitHub
parent
dd6fe6a04a
commit
45fe3be83e
@ -255,13 +255,13 @@ impl From<FileInfo> for Value {
|
||||
});
|
||||
|
||||
cols.push("directories".into());
|
||||
vals.push(Value::nothing(Span::test_data()));
|
||||
vals.push(Value::nothing(Span::unknown()));
|
||||
|
||||
cols.push("files".into());
|
||||
vals.push(Value::nothing(Span::test_data()));
|
||||
vals.push(Value::nothing(Span::unknown()));
|
||||
|
||||
// cols.push("errors".into());
|
||||
// vals.push(Value::nothing(Span::test_data()));
|
||||
// vals.push(Value::nothing(Span::unknown()));
|
||||
|
||||
Value::Record {
|
||||
cols,
|
||||
|
@ -93,7 +93,7 @@ pub fn print_events(engine_state: &EngineState) -> Result<Value, ShellError> {
|
||||
}
|
||||
terminal::disable_raw_mode()?;
|
||||
|
||||
Ok(Value::nothing(Span::test_data()))
|
||||
Ok(Value::nothing(Span::unknown()))
|
||||
}
|
||||
|
||||
// this fn is totally ripped off from crossterm's examples
|
||||
@ -113,12 +113,12 @@ fn print_events_helper(event: Event) -> Result<Value, ShellError> {
|
||||
"flags".into(),
|
||||
],
|
||||
vals: vec![
|
||||
Value::string(format!("{}", c), Span::test_data()),
|
||||
Value::string(format!("{:#08x}", u32::from(c)), Span::test_data()),
|
||||
Value::string(format!("{:?}", modifiers), Span::test_data()),
|
||||
Value::string(format!("{:#08b}", modifiers), Span::test_data()),
|
||||
Value::string(format!("{}", c), Span::unknown()),
|
||||
Value::string(format!("{:#08x}", u32::from(c)), Span::unknown()),
|
||||
Value::string(format!("{:?}", modifiers), Span::unknown()),
|
||||
Value::string(format!("{:#08b}", modifiers), Span::unknown()),
|
||||
],
|
||||
span: Span::test_data(),
|
||||
span: Span::unknown(),
|
||||
};
|
||||
Ok(record)
|
||||
}
|
||||
@ -126,11 +126,11 @@ fn print_events_helper(event: Event) -> Result<Value, ShellError> {
|
||||
let record = Value::Record {
|
||||
cols: vec!["code".into(), "modifier".into(), "flags".into()],
|
||||
vals: vec![
|
||||
Value::string(format!("{:?}", code), Span::test_data()),
|
||||
Value::string(format!("{:?}", modifiers), Span::test_data()),
|
||||
Value::string(format!("{:#08b}", modifiers), Span::test_data()),
|
||||
Value::string(format!("{:?}", code), Span::unknown()),
|
||||
Value::string(format!("{:?}", modifiers), Span::unknown()),
|
||||
Value::string(format!("{:#08b}", modifiers), Span::unknown()),
|
||||
],
|
||||
span: Span::test_data(),
|
||||
span: Span::unknown(),
|
||||
};
|
||||
Ok(record)
|
||||
}
|
||||
@ -138,8 +138,8 @@ fn print_events_helper(event: Event) -> Result<Value, ShellError> {
|
||||
} else {
|
||||
let record = Value::Record {
|
||||
cols: vec!["event".into()],
|
||||
vals: vec![Value::string(format!("{:?}", event), Span::test_data())],
|
||||
span: Span::test_data(),
|
||||
vals: vec![Value::string(format!("{:?}", event), Span::unknown())],
|
||||
span: Span::unknown(),
|
||||
};
|
||||
Ok(record)
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{
|
||||
Category, Example, IntoPipelineData, PipelineData, Signature, Span, Type, Value,
|
||||
};
|
||||
use nu_protocol::{Category, Example, IntoPipelineData, PipelineData, Signature, Type, Value};
|
||||
use terminal_size::{terminal_size, Height, Width};
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -66,8 +64,8 @@ impl Command for TermSize {
|
||||
Ok(Value::Record {
|
||||
cols: vec!["columns".into(), "rows".into()],
|
||||
vals: vec![
|
||||
Value::int(cols.0 as i64, Span::test_data()),
|
||||
Value::int(rows.0 as i64, Span::test_data()),
|
||||
Value::int(cols.0 as i64, head),
|
||||
Value::int(rows.0 as i64, head),
|
||||
],
|
||||
span: head,
|
||||
}
|
||||
|
Reference in New Issue
Block a user