Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 23 additions & 3 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ pub struct Args {
#[serde(default)]
pub jwt_from_file: bool,


#[options(
no_short,
help = "OAuth environment to use (e.g., 'app' or 'staging'). Used for Service Account authentication",
Expand Down Expand Up @@ -113,6 +112,10 @@ pub struct Args {
#[serde(skip_serializing, skip_deserializing)]
pub update_defaults: bool,

#[options(no_short, help = "Disable syntax highlighting in REPL")]
#[serde(default)]
pub no_color: bool,

#[options(help = "Print version")]
#[serde(default)]
pub version: bool,
Expand All @@ -136,7 +139,7 @@ impl Args {
/// "client:auto" → "auto", "client:vertical" → "vertical", "PSQL" → ""
pub fn get_display_mode(&self) -> &str {
if self.format.starts_with("client:") {
&self.format[7..] // Skip "client:" prefix
&self.format[7..] // Skip "client:" prefix
} else {
""
}
Expand All @@ -153,6 +156,22 @@ impl Args {
pub fn is_auto_display(&self) -> bool {
self.get_display_mode().eq_ignore_ascii_case("auto")
}

/// Determine if colors should be used for syntax highlighting
pub fn should_use_colors(&self) -> bool {
// Check NO_COLOR environment variable (standard: no-color.org)
if std::env::var("NO_COLOR").is_ok() {
return false;
}

// Check command-line flag
if self.no_color {
return false;
}

// Default: use colors
true
}
}

pub fn normalize_extras(extras: Vec<String>, encode: bool) -> Result<Vec<String>, Box<dyn std::error::Error>> {
Expand Down Expand Up @@ -281,7 +300,8 @@ pub fn get_args() -> Result<Args, Box<dyn std::error::Error>> {
// Warn if user specified a client format name without the "client:" prefix
if args.format.eq_ignore_ascii_case("auto")
|| args.format.eq_ignore_ascii_case("vertical")
|| args.format.eq_ignore_ascii_case("horizontal") {
|| args.format.eq_ignore_ascii_case("horizontal")
{
eprintln!("Warning: Format '{}' is not supported by the server.", args.format);
eprintln!("Did you mean '--format client:{}'?", args.format.to_lowercase());
eprintln!("Client-side formats require the 'client:' prefix (e.g., client:auto, client:vertical, client:horizontal)");
Expand Down
Loading