mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 08:23:24 +01:00
allows for nushell to have tables without the index column (#5380)
This commit is contained in:
parent
1fc7abcc38
commit
5999506f87
@ -304,9 +304,10 @@ fn convert_to_table(
|
|||||||
let mut input = input.iter().peekable();
|
let mut input = input.iter().peekable();
|
||||||
let color_hm = get_color_config(config);
|
let color_hm = get_color_config(config);
|
||||||
let float_precision = config.float_precision as usize;
|
let float_precision = config.float_precision as usize;
|
||||||
|
let disable_index = config.disable_table_indexes;
|
||||||
|
|
||||||
if input.peek().is_some() {
|
if input.peek().is_some() {
|
||||||
if !headers.is_empty() {
|
if !headers.is_empty() && !disable_index {
|
||||||
headers.insert(0, "#".into());
|
headers.insert(0, "#".into());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,16 +324,19 @@ fn convert_to_table(
|
|||||||
return Err(error.clone());
|
return Err(error.clone());
|
||||||
}
|
}
|
||||||
// String1 = datatype, String2 = value as string
|
// String1 = datatype, String2 = value as string
|
||||||
let mut row: Vec<(String, String)> =
|
let mut row: Vec<(String, String)> = vec![];
|
||||||
vec![("string".to_string(), (row_num + row_offset).to_string())];
|
if !disable_index {
|
||||||
|
row = vec![("string".to_string(), (row_num + row_offset).to_string())];
|
||||||
|
}
|
||||||
|
|
||||||
if headers.is_empty() {
|
if headers.is_empty() {
|
||||||
row.push((
|
row.push((
|
||||||
item.get_type().to_string(),
|
item.get_type().to_string(),
|
||||||
item.into_abbreviated_string(config),
|
item.into_abbreviated_string(config),
|
||||||
))
|
));
|
||||||
} else {
|
} else {
|
||||||
for header in headers.iter().skip(1) {
|
let skip_num = if !disable_index { 1 } else { 0 };
|
||||||
|
for header in headers.iter().skip(skip_num) {
|
||||||
let result = match item {
|
let result = match item {
|
||||||
Value::Record { .. } => {
|
Value::Record { .. } => {
|
||||||
item.clone().follow_cell_path(&[PathMember::String {
|
item.clone().follow_cell_path(&[PathMember::String {
|
||||||
@ -373,7 +377,7 @@ fn convert_to_table(
|
|||||||
x.into_iter()
|
x.into_iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(col, y)| {
|
.map(|(col, y)| {
|
||||||
if col == 0 {
|
if col == 0 && !disable_index {
|
||||||
StyledString {
|
StyledString {
|
||||||
contents: y.1,
|
contents: y.1,
|
||||||
style: TextStyle {
|
style: TextStyle {
|
||||||
|
@ -47,6 +47,7 @@ pub struct Config {
|
|||||||
pub menus: Vec<ParsedMenu>,
|
pub menus: Vec<ParsedMenu>,
|
||||||
pub rm_always_trash: bool,
|
pub rm_always_trash: bool,
|
||||||
pub shell_integration: bool,
|
pub shell_integration: bool,
|
||||||
|
pub disable_table_indexes: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Config {
|
impl Default for Config {
|
||||||
@ -73,6 +74,7 @@ impl Default for Config {
|
|||||||
menus: Vec::new(),
|
menus: Vec::new(),
|
||||||
rm_always_trash: false,
|
rm_always_trash: false,
|
||||||
shell_integration: false,
|
shell_integration: false,
|
||||||
|
disable_table_indexes: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,7 +256,13 @@ impl Value {
|
|||||||
eprintln!("$config.shell_integration is not a bool")
|
eprintln!("$config.shell_integration is not a bool")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
"disable_table_indexes" => {
|
||||||
|
if let Ok(b) = value.as_bool() {
|
||||||
|
config.disable_table_indexes = b;
|
||||||
|
} else {
|
||||||
|
eprintln!("$config.disable_table_indexes is not a bool")
|
||||||
|
}
|
||||||
|
}
|
||||||
x => {
|
x => {
|
||||||
eprintln!("$config.{} is an unknown config setting", x)
|
eprintln!("$config.{} is an unknown config setting", x)
|
||||||
}
|
}
|
||||||
|
@ -196,6 +196,7 @@ let-env config = {
|
|||||||
max_history_size: 10000 # Session has to be reloaded for this to take effect
|
max_history_size: 10000 # Session has to be reloaded for this to take effect
|
||||||
sync_history_on_enter: true # Enable to share the history between multiple sessions, else you have to close the session to persist history to file
|
sync_history_on_enter: true # Enable to share the history between multiple sessions, else you have to close the session to persist history to file
|
||||||
shell_integration: true # enables terminal markers and a workaround to arrow keys stop working issue
|
shell_integration: true # enables terminal markers and a workaround to arrow keys stop working issue
|
||||||
|
disable_table_indexes: false # set to true to remove the index column from tables
|
||||||
menus: [
|
menus: [
|
||||||
# Configuration for default nushell menus
|
# Configuration for default nushell menus
|
||||||
# Note the lack of souce parameter
|
# Note the lack of souce parameter
|
||||||
|
Loading…
Reference in New Issue
Block a user