Skip to main content

OutputConfig

Struct OutputConfig 

Source
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: bool

Whether 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: OutputTarget

Output 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: bool

Whether to overwrite existing files when writing to a file target. Only relevant when target is File.

Implementations§

Source§

impl OutputConfig

Source

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 values
  • no_color_flag - The --no-color CLI flag (if present, overrides config)
  • limit_flag - The --limit CLI flag (if present, overrides config)
  • page_size_flag - The --page-size CLI flag (if present, overrides config)
  • output_flag - The --output CLI flag for file destination
  • overwrite_flag - The --overwrite CLI 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

Source§

fn clone(&self) -> OutputConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OutputConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for OutputConfig

Source§

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§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more