pub struct OutputConfig {
pub color_enabled: bool,
pub limit: Option<usize>,
pub page_size: Option<usize>,
pub target: OutputTarget,
pub overwrite: bool,
}Expand description
Configuration for table formatter output behavior
This struct controls how query results are formatted and displayed, including color support, row limits, pagination settings, and output destination.
Fields§
§color_enabled: boolWhether to enable colored output in table formatting.
This is the inverse of the --no-color CLI flag.
When true, output will include ANSI color codes for better readability.
limit: Option<usize>Maximum number of rows to display in query results.
When None, all rows will be displayed.
This can be used to prevent overwhelming output from large result sets.
page_size: Option<usize>Number of rows per page for pagination.
When None, pagination is disabled and all rows are shown at once.
Default is 50 rows per page, matching cqlsh behavior.
target: OutputTargetOutput target (stdout or file path).
When Stdout, output is written to standard output.
When File(path), output is written atomically to the specified file.
overwrite: boolWhether to overwrite existing files when writing to a file target.
Only relevant when target is File.
Implementations§
Source§impl OutputConfig
impl OutputConfig
Sourcepub fn from_cli(
config: &Config,
no_color_flag: bool,
limit_flag: Option<usize>,
page_size_flag: Option<usize>,
output_flag: Option<PathBuf>,
overwrite_flag: bool,
) -> Self
pub fn from_cli( config: &Config, no_color_flag: bool, limit_flag: Option<usize>, page_size_flag: Option<usize>, output_flag: Option<PathBuf>, overwrite_flag: bool, ) -> Self
Create a new OutputConfig from resolved Config and CLI flags
This method respects the precedence chain: CLI flags > env vars > config file > defaults.
The Config object passed in has already resolved this chain via ConfigBuilder.
§Arguments
config- The resolved Config object containing env/file/default valuesno_color_flag- The--no-colorCLI flag (if present, overrides config)limit_flag- The--limitCLI flag (if present, overrides config)page_size_flag- The--page-sizeCLI flag (if present, overrides config)output_flag- The--outputCLI flag for file destinationoverwrite_flag- The--overwriteCLI flag for overwriting existing files
§Precedence
color_enabled: –no-color flag > CQLITE_NO_COLOR env > config.output.colors > default (true)limit: –limit flag > CQLITE_LIMIT env > config.query_limit > default (None)page_size: –page-size flag > CQLITE_PAGE_SIZE env > config.repl.page_size > default (50)target: –output flag > CQLITE_OUTPUT env > default (Stdout)overwrite: –overwrite flag > default (false)
§Examples
use cqlite_cli::config::{Config, OutputConfig};
use cqlite_cli::cli_types::Cli;
use clap::Parser;
// Create config with defaults
let cli = Cli::parse_from(&["cqlite"]);
let config = Config::load(None, &cli).unwrap();
let output = OutputConfig::from_cli(&config, false, None, None, None, false);
assert!(output.color_enabled);
assert_eq!(output.page_size, Some(50));
// CLI flag overrides config
let output = OutputConfig::from_cli(&config, true, Some(100), Some(25), None, false);
assert!(!output.color_enabled);
assert_eq!(output.limit, Some(100));
assert_eq!(output.page_size, Some(25));Trait Implementations§
Source§impl Clone for OutputConfig
impl Clone for OutputConfig
Source§fn clone(&self) -> OutputConfig
fn clone(&self) -> OutputConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OutputConfig
impl Debug for OutputConfig
Source§impl Default for OutputConfig
impl Default for OutputConfig
Source§fn default() -> Self
fn default() -> Self
Default output configuration
Returns an OutputConfig with:
color_enabled:true(colors enabled by default)limit:None(no row limit)page_size:Some(50)(50 rows per page, matching cqlsh)target:Stdout(write to standard output)overwrite:false(don’t overwrite existing files)
Auto Trait Implementations§
impl Freeze for OutputConfig
impl RefUnwindSafe for OutputConfig
impl Send for OutputConfig
impl Sync for OutputConfig
impl Unpin for OutputConfig
impl UnsafeUnpin for OutputConfig
impl UnwindSafe for OutputConfig
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more