mirror of
https://github.com/nushell/nushell.git
synced 2025-08-18 09:29:48 +02:00
Finish up heuristic for table printing
This commit is contained in:
@@ -7,7 +7,9 @@ use futures_async_stream::async_stream_block;
|
||||
pub struct Table;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct TableArgs {}
|
||||
pub struct TableArgs {
|
||||
full: bool,
|
||||
}
|
||||
|
||||
impl StaticCommand for Table {
|
||||
fn name(&self) -> &str {
|
||||
@@ -21,16 +23,19 @@ impl StaticCommand for Table {
|
||||
args.process(registry, table)?.run()
|
||||
}
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("table")
|
||||
Signature::build("table").switch("full")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn table(_args: TableArgs, context: RunnableContext) -> Result<OutputStream, ShellError> {
|
||||
pub fn table(
|
||||
TableArgs { full }: TableArgs,
|
||||
context: RunnableContext,
|
||||
) -> Result<OutputStream, ShellError> {
|
||||
let stream = async_stream_block! {
|
||||
let input: Vec<Tagged<Value>> = context.input.into_vec().await;
|
||||
if input.len() > 0 {
|
||||
let mut host = context.host.lock().unwrap();
|
||||
let view = TableView::from_list(&input);
|
||||
let view = TableView::from_list(&input, full);
|
||||
if let Some(view) = view {
|
||||
handle_unexpected(&mut *host, |host| crate::format::print_view(&view, host));
|
||||
}
|
||||
|
Reference in New Issue
Block a user