diff --git a/module/move/assistant/src/bin/list_resources.rs b/module/move/assistant/src/bin/list_resources.rs index 5c3a4a85bb..d85d524ceb 100644 --- a/module/move/assistant/src/bin/list_resources.rs +++ b/module/move/assistant/src/bin/list_resources.rs @@ -19,7 +19,7 @@ use dotenv::dotenv; use assistant:: { - client, + client::client, Secret }; diff --git a/module/move/assistant/src/commands.rs b/module/move/assistant/src/commands.rs index 7f54ec320b..480b13d8d5 100644 --- a/module/move/assistant/src/commands.rs +++ b/module/move/assistant/src/commands.rs @@ -29,17 +29,15 @@ mod private OpenAi( openai::Command ), } - // const DEFAULT_MAX_TABLE_WIDTH: usize = 130; - // Commented out as not yet implemented in `format_tools`. + const DEFAULT_MAX_TABLE_WIDTH : usize = 130; /// Common collection of arguments for formatting tabular data. #[ derive( Debug, Parser ) ] pub struct TableConfig { /// Limit table widht. - // #[ arg( long, default_value_t = DEFAULT_MAX_TABLE_WIDTH ) ] - // pub max_table_width : usize, - // Commented out as not yet implemented in `format_tools`. + #[ arg( long, default_value_t = DEFAULT_MAX_TABLE_WIDTH ) ] + pub max_table_width : usize, /// Show tabular data as an ordinary table. #[ arg( long ) ] diff --git a/module/move/assistant/src/util/display_table.rs b/module/move/assistant/src/util/display_table.rs index edced5fbdd..c4e7ddcd28 100644 --- a/module/move/assistant/src/util/display_table.rs +++ b/module/move/assistant/src/util/display_table.rs @@ -28,19 +28,19 @@ mod private { if table_config.as_table { - display_table( data, f, &table_config.filter_columns ) + display_table( data, f, table_config ) } else if table_config.as_records { - display_records( data, f, &table_config.filter_columns ) + display_records( data, f, table_config ) } else if table_config.columns { - display_columns( data, f, &table_config.filter_columns ) + display_columns( data, f, table_config ) } else { - display_table( data, f, &table_config.filter_columns ) + display_table( data, f, table_config ) } } @@ -48,38 +48,65 @@ mod private ( data : &'a impl TableFormatter< 'a >, f : &mut fmt::Formatter< '_ >, - filter_columns : &'a Vec< String >, + table_config : &'a TableConfig, ) -> fmt::Result { - display_data( data, f, filter_columns, output_format::Table::default() ) + let mut format = output_format::Table::default(); + format.max_width = table_config.max_table_width; + + display_data + ( + data, + f, + format, + &table_config.filter_columns, + ) } fn display_records<'a> ( data : &'a impl TableFormatter< 'a >, f : &mut fmt::Formatter< '_ >, - filter_columns : &'a Vec< String >, + table_config : &'a TableConfig, ) -> fmt::Result { - display_data( data, f, filter_columns, output_format::Records::default() ) + let mut format = output_format::Records::default(); + format.max_width = table_config.max_table_width; + + display_data + ( + data, + f, + format, + &table_config.filter_columns, + ) } fn display_columns<'a> ( data : &'a impl TableFormatter< 'a >, f : &mut fmt::Formatter< '_ >, - filter_columns : &'a Vec< String >, + table_config : &'a TableConfig, ) -> fmt::Result { - display_data( data, f, filter_columns, output_format::Keys::default() ) + let mut format = output_format::Records::default(); + format.max_width = table_config.max_table_width; + + display_data + ( + data, + f, + format, + &table_config.filter_columns, + ) } fn display_data<'a> ( data : &'a impl TableFormatter< 'a >, f : &mut fmt::Formatter< '_ >, - filter_columns : &'a Vec< String >, format : impl TableOutputFormat, + filter_columns : &'a Vec< String >, ) -> fmt::Result { let mut printer = print::Printer::with_format( &format );