mirror of
https://github.com/nushell/nushell.git
synced 2025-03-30 18:46:29 +02:00
Edited help text and examples in explore
for readability (#7324)
# Description * Various help messages were edited for clarity/grammar/etc. * Some examples were made more interesting or relevant # User-Facing Changes See above. # Tests + Formatting Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass # After Submitting If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date.
This commit is contained in:
parent
fcdc474731
commit
5762489070
@ -31,16 +31,20 @@ impl Command for Explore {
|
|||||||
.named(
|
.named(
|
||||||
"head",
|
"head",
|
||||||
SyntaxShape::Boolean,
|
SyntaxShape::Boolean,
|
||||||
"Setting it to false makes it doesn't show column headers",
|
"Show or hide column headers (default true)",
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
.switch("index", "A flag to show a index beside the rows", Some('i'))
|
.switch("index", "Show row indexes when viewing a list", Some('i'))
|
||||||
.switch(
|
.switch(
|
||||||
"reverse",
|
"reverse",
|
||||||
"Makes it start from the end. (like `more`)",
|
"Start with the viewport scrolled to the bottom",
|
||||||
Some('r'),
|
Some('r'),
|
||||||
)
|
)
|
||||||
.switch("peek", "Return a last seen cell content", Some('p'))
|
.switch(
|
||||||
|
"peek",
|
||||||
|
"When quitting, output the value of the cell the cursor was on",
|
||||||
|
Some('p'),
|
||||||
|
)
|
||||||
.category(Category::Viewers)
|
.category(Category::Viewers)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,23 +94,24 @@ impl Command for Explore {
|
|||||||
fn examples(&self) -> Vec<Example> {
|
fn examples(&self) -> Vec<Example> {
|
||||||
vec![
|
vec![
|
||||||
Example {
|
Example {
|
||||||
description: "List the files in current directory, an looking at them via explore.",
|
description: "Explore the system information record",
|
||||||
example: r#"ls | explore"#,
|
example: r#"sys | explore"#,
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Inspect system information (explore with index).",
|
description: "Explore the output of `ls` without column names",
|
||||||
example: r#"sys | explore -i"#,
|
example: r#"ls | explore --head false"#,
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Inspect $nu information (explore with no column names).",
|
description: "Explore a list of Markdown files' contents, with row indexes",
|
||||||
example: r#"$nu | explore --head false"#,
|
example: r#"glob *.md | each { open } | explore -i"#,
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
Example {
|
Example {
|
||||||
description: "Inspect $nu information and return an entity where you've stopped.",
|
description:
|
||||||
example: r#"$nu | explore --peek"#,
|
"Explore a JSON file, then save the last visited sub-structure to a file",
|
||||||
|
example: r#"open file.json | explore -p | to json | save part.json"#,
|
||||||
result: None,
|
result: None,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@ -64,16 +64,16 @@ impl ViewCommand for HelpCmd {
|
|||||||
fn help(&self) -> Option<HelpManual> {
|
fn help(&self) -> Option<HelpManual> {
|
||||||
Some(HelpManual {
|
Some(HelpManual {
|
||||||
name: "help",
|
name: "help",
|
||||||
description: "Looks up a help information about a command or a `explore`",
|
description: "Explore the help page for `explore`",
|
||||||
arguments: vec![],
|
arguments: vec![],
|
||||||
examples: vec![
|
examples: vec![
|
||||||
HelpExample {
|
HelpExample {
|
||||||
example: "help",
|
example: "help",
|
||||||
description: "Open a help information about the `explore`",
|
description: "Open the help page for all of `explore`",
|
||||||
},
|
},
|
||||||
HelpExample {
|
HelpExample {
|
||||||
example: "help nu",
|
example: "help nu",
|
||||||
description: "Find a help list of `nu` command",
|
description: "Open the help page for the `nu` explore command",
|
||||||
},
|
},
|
||||||
HelpExample {
|
HelpExample {
|
||||||
example: "help help",
|
example: "help help",
|
||||||
@ -161,20 +161,20 @@ fn help_frame_data(
|
|||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
let shortcuts = [
|
let shortcuts = [
|
||||||
(":", "view", commands, "Run a command"),
|
(":", "view", commands, "Run an explore command (explore the 'information' cell of this row to list commands)"),
|
||||||
("/", "view", null!(), "Search via pattern"),
|
("/", "view", null!(), "Search for a pattern"),
|
||||||
("?", "view", null!(), "Search via pattern but results will be reversed when you press <n>"),
|
("?", "view", null!(), "Search for a pattern, but the <n> key now scrolls to the previous result"),
|
||||||
("n", "view", null!(), "Gets to the next found element in search"),
|
("n", "view", null!(), "When searching, scroll to the next search result"),
|
||||||
("i", "view", null!(), "Turn on a cursor mode so you can inspect values"),
|
("i", "view", null!(), "Enters cursor mode to inspect individual cells"),
|
||||||
("t", "view", null!(), "Transpose table, so columns became rows and vice versa"),
|
("t", "view", null!(), "Transpose table, so that columns become rows and vice versa"),
|
||||||
("Up", "", null!(), "Moves to an element above"),
|
("Up", "", null!(), "Moves the cursor or viewport one row up"),
|
||||||
("Down", "", null!(), "Moves to an element bellow"),
|
("Down", "", null!(), "Moves the cursor or viewport one row down"),
|
||||||
("Left", "", null!(), "Moves to an element to the left"),
|
("Left", "", null!(), "Moves the cursor or viewport one column left"),
|
||||||
("Right", "", null!(), "Moves to an element to the right"),
|
("Right", "", null!(), "Moves the cursor or viewport one column right"),
|
||||||
("PgDown", "view", null!(), "Moves to an a bunch of elements bellow"),
|
("PgDown", "view", null!(), "Moves the cursor or viewport one page of rows down"),
|
||||||
("PgUp", "view", null!(), "Moves to an a bunch of elements above"),
|
("PgUp", "view", null!(), "Moves the cursor or viewport one page of rows up"),
|
||||||
("Esc", "", null!(), "Exits a cursor mode. Exists an expected element."),
|
("Esc", "", null!(), "Exits cursor mode. Exits the currently explored data."),
|
||||||
("Enter", "cursor", null!(), "Inspect a chosen element"),
|
("Enter", "cursor", null!(), "In cursor mode, explore the data of the selected cell"),
|
||||||
];
|
];
|
||||||
|
|
||||||
let headers = headers.iter().map(|s| s.to_string()).collect();
|
let headers = headers.iter().map(|s| s.to_string()).collect();
|
||||||
|
@ -44,16 +44,17 @@ impl ViewCommand for NuCmd {
|
|||||||
fn help(&self) -> Option<HelpManual> {
|
fn help(&self) -> Option<HelpManual> {
|
||||||
Some(HelpManual {
|
Some(HelpManual {
|
||||||
name: "nu",
|
name: "nu",
|
||||||
description: "Run a nu command. You can use a presented table as an input",
|
description:
|
||||||
|
"Run a Nushell command. The data currently being explored is piped into it.",
|
||||||
arguments: vec![],
|
arguments: vec![],
|
||||||
examples: vec![
|
examples: vec![
|
||||||
HelpExample {
|
HelpExample {
|
||||||
example: "where type == 'file'",
|
example: "where type == 'file'",
|
||||||
description: "Filter data to get only entries with a type being a 'file'",
|
description: "Filter data to show only rows whose type is 'file'",
|
||||||
},
|
},
|
||||||
HelpExample {
|
HelpExample {
|
||||||
example: "get scope | get examples",
|
example: "get scope.examples",
|
||||||
description: "Get a inner values",
|
description: "Navigate to a deeper value inside the data",
|
||||||
},
|
},
|
||||||
HelpExample {
|
HelpExample {
|
||||||
example: "open Cargo.toml",
|
example: "open Cargo.toml",
|
||||||
|
@ -40,7 +40,8 @@ impl ViewCommand for PreviewCmd {
|
|||||||
fn help(&self) -> Option<HelpManual> {
|
fn help(&self) -> Option<HelpManual> {
|
||||||
Some(HelpManual {
|
Some(HelpManual {
|
||||||
name: "preview",
|
name: "preview",
|
||||||
description: "Preview current value/table if any is currently in use",
|
description:
|
||||||
|
"View the currently selected cell's data using the `table` Nushell command",
|
||||||
arguments: vec![],
|
arguments: vec![],
|
||||||
examples: vec![],
|
examples: vec![],
|
||||||
})
|
})
|
||||||
|
@ -28,7 +28,7 @@ impl SimpleCommand for QuitCmd {
|
|||||||
fn help(&self) -> Option<HelpManual> {
|
fn help(&self) -> Option<HelpManual> {
|
||||||
Some(HelpManual {
|
Some(HelpManual {
|
||||||
name: "quit",
|
name: "quit",
|
||||||
description: "Quit",
|
description: "Quit and return to Nushell",
|
||||||
arguments: vec![],
|
arguments: vec![],
|
||||||
examples: vec![],
|
examples: vec![],
|
||||||
})
|
})
|
||||||
|
@ -40,11 +40,11 @@ impl ViewCommand for TryCmd {
|
|||||||
fn help(&self) -> Option<HelpManual> {
|
fn help(&self) -> Option<HelpManual> {
|
||||||
Some(HelpManual {
|
Some(HelpManual {
|
||||||
name: "try",
|
name: "try",
|
||||||
description: "Opens a dynamic REPL to run nu commands",
|
description: "Opens a panel in which to run Nushell commands and explore their output",
|
||||||
arguments: vec![],
|
arguments: vec![],
|
||||||
examples: vec![HelpExample {
|
examples: vec![HelpExample {
|
||||||
example: "try open Cargo.toml",
|
example: "try open Cargo.toml",
|
||||||
description: "Optionally you can provide a command which will be run right away",
|
description: "Optionally, you can provide a command which will be run immediately",
|
||||||
}],
|
}],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -329,7 +329,7 @@ fn render_status_bar(f: &mut Frame, area: Rect, report: Report, theme: &StyleCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn report_msg_style(report: &Report, theme: &StyleConfig, style: NuStyle) -> NuStyle {
|
fn report_msg_style(report: &Report, theme: &StyleConfig, style: NuStyle) -> NuStyle {
|
||||||
if matches!(report.level, Severentity::Info) {
|
if matches!(report.level, Severity::Info) {
|
||||||
style
|
style
|
||||||
} else {
|
} else {
|
||||||
report_level_style(report.level, theme)
|
report_level_style(report.level, theme)
|
||||||
@ -834,11 +834,11 @@ impl Widget for StatusBar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn report_level_style(level: Severentity, theme: &StyleConfig) -> NuStyle {
|
fn report_level_style(level: Severity, theme: &StyleConfig) -> NuStyle {
|
||||||
match level {
|
match level {
|
||||||
Severentity::Info => theme.status_info,
|
Severity::Info => theme.status_info,
|
||||||
Severentity::Warn => theme.status_warn,
|
Severity::Warn => theme.status_warn,
|
||||||
Severentity::Err => theme.status_error,
|
Severity::Err => theme.status_error,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -935,13 +935,13 @@ pub struct ViewInfo {
|
|||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Report {
|
pub struct Report {
|
||||||
pub message: String,
|
pub message: String,
|
||||||
pub level: Severentity,
|
pub level: Severity,
|
||||||
pub context: String,
|
pub context: String,
|
||||||
pub context2: String,
|
pub context2: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Report {
|
impl Report {
|
||||||
pub fn new(message: String, level: Severentity, context: String, context2: String) -> Self {
|
pub fn new(message: String, level: Severity, context: String, context2: String) -> Self {
|
||||||
Self {
|
Self {
|
||||||
message,
|
message,
|
||||||
level,
|
level,
|
||||||
@ -951,28 +951,18 @@ impl Report {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn error(message: impl Into<String>) -> Self {
|
pub fn error(message: impl Into<String>) -> Self {
|
||||||
Self::new(
|
Self::new(message.into(), Severity::Err, String::new(), String::new())
|
||||||
message.into(),
|
|
||||||
Severentity::Err,
|
|
||||||
String::new(),
|
|
||||||
String::new(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Report {
|
impl Default for Report {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::new(
|
Self::new(String::new(), Severity::Info, String::new(), String::new())
|
||||||
String::new(),
|
|
||||||
Severentity::Info,
|
|
||||||
String::new(),
|
|
||||||
String::new(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub enum Severentity {
|
pub enum Severity {
|
||||||
Info,
|
Info,
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
Warn,
|
Warn,
|
||||||
|
@ -10,7 +10,7 @@ use tui::layout::Rect;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
nu_common::{NuSpan, NuText},
|
nu_common::{NuSpan, NuText},
|
||||||
pager::{Frame, Report, Severentity, Transition, ViewConfig, ViewInfo},
|
pager::{Frame, Report, Severity, Transition, ViewConfig, ViewInfo},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{coloredtextw::ColoredTextW, Layout, View};
|
use super::{coloredtextw::ColoredTextW, Layout, View};
|
||||||
@ -105,7 +105,7 @@ impl View for Preview {
|
|||||||
if is_end {
|
if is_end {
|
||||||
let report = Report::new(
|
let report = Report::new(
|
||||||
String::from("END"),
|
String::from("END"),
|
||||||
Severentity::Info,
|
Severity::Info,
|
||||||
String::new(),
|
String::new(),
|
||||||
String::new(),
|
String::new(),
|
||||||
);
|
);
|
||||||
@ -137,7 +137,7 @@ impl View for Preview {
|
|||||||
if is_end {
|
if is_end {
|
||||||
let report = Report::new(
|
let report = Report::new(
|
||||||
String::from("END"),
|
String::from("END"),
|
||||||
Severentity::Info,
|
Severity::Info,
|
||||||
String::new(),
|
String::new(),
|
||||||
String::new(),
|
String::new(),
|
||||||
);
|
);
|
||||||
|
@ -12,7 +12,7 @@ use tui::{layout::Rect, widgets::Block};
|
|||||||
use crate::{
|
use crate::{
|
||||||
nu_common::{collect_input, NuConfig, NuSpan, NuStyleTable, NuText},
|
nu_common::{collect_input, NuConfig, NuSpan, NuStyleTable, NuText},
|
||||||
pager::{
|
pager::{
|
||||||
make_styled_string, nu_style_to_tui, Frame, Position, Report, Severentity, StyleConfig,
|
make_styled_string, nu_style_to_tui, Frame, Position, Report, Severity, StyleConfig,
|
||||||
TableConfig, Transition, ViewConfig, ViewInfo,
|
TableConfig, Transition, ViewConfig, ViewInfo,
|
||||||
},
|
},
|
||||||
views::ElementInfo,
|
views::ElementInfo,
|
||||||
@ -584,7 +584,7 @@ fn create_records_report(
|
|||||||
message: title,
|
message: title,
|
||||||
context: covered_percent,
|
context: covered_percent,
|
||||||
context2: cursor,
|
context2: cursor,
|
||||||
level: Severentity::Info,
|
level: Severity::Info,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user