Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Disable client console highlight by default #9013

Merged
merged 4 commits into from
Jan 27, 2024
Merged

Conversation

comphead
Copy link
Contributor

Which issue does this PR close?

Closes #.

Rationale for this change

The syntax highlight has been introduced in #8918. Thanks again @trungda

Some users is not comfortable with new syntax highlight, so the PR makes it optional. The user can enable coloring providing color flag datafusion-cli --color

For now the syntax highlight put as disabled by default, my humble vision its a little bit experimental and we may want to improve the color schema to be more smooth.

What changes are included in this PR?

introduced NoColor strategy and the color provider gets enabled by the --color flag

Are these changes tested?

Yes, manually

Are there any user-facing changes?

No

Copy link
Contributor

@trungda trungda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @comphead! I should have done this myself. I guess depending on the terminal setup, the color scheme can be either smooth or not.

@@ -136,6 +136,9 @@ struct Args {
default_value = "40"
)]
maxrows: MaxRows,

#[clap(long, help = "Enables console syntax highlighting")]
color: bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe call this syntax_highlighting?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another potential option might be to follow the duckdb lead and call it ascii output mode 🤔 (when there is no color)

andrewlamb@Andrews-MacBook-Pro:~/Software/influxdb_iox$ duckdb --help
Usage: duckdb [OPTIONS] FILENAME [SQL]
FILENAME is the name of an DuckDB database. A new database is created
if the file does not previously exist.
OPTIONS include:
   -append              append the database to the end of the file
   -ascii               set output mode to 'ascii'
   -bail                stop after hitting an error
   -batch               force batch I/O
   -box                 set output mode to 'box'
   -column              set output mode to 'column'
   -cmd COMMAND         run "COMMAND" before reading stdin
   -c COMMAND           run "COMMAND" and exit
   -csv                 set output mode to 'csv'
   -echo                print commands before execution
   -init FILENAME       read/process named file
   -[no]header          turn headers on or off
   -help                show this message
   -html                set output mode to HTML
   -interactive         force interactive I/O
   -json                set output mode to 'json'
   -line                set output mode to 'line'
   -list                set output mode to 'list'
   -markdown            set output mode to 'markdown'
   -newline SEP         set output row separator. Default: '\n'
   -nofollow            refuse to open symbolic links to database files
   -no-stdin            exit after processing options instead of reading stdin
   -nullvalue TEXT      set text string for NULL values. Default ''
   -quote               set output mode to 'quote'
   -readonly            open the database read-only
   -s COMMAND           run "COMMAND" and exit
   -separator SEP       set output column separator. Default: '|'
   -stats               print memory stats before each finalize
   -table               set output mode to 'table'
   -unsigned            allow loading of unsigned extensions
   -version             show DuckDB version

Self { dialect }
}
}

pub struct NoSyntaxSyntaxHighlighter {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NoSyntaxHighlighter (Syntax is duplicate)?

@comphead
Copy link
Contributor Author

Thank you @comphead! I should have done this myself. I guess depending on the terminal setup, the color scheme can be either smooth or not.

Thanks @trungda. I really love we started the coloring/customizing, appearance is what people buy :) and now we have all the code inside, and both users and developers can now experiment and come up with solution. It can even a factory of solutions, different schemas, etc

@alamb would you mind sharing your opinion?

@alamb
Copy link
Contributor

alamb commented Jan 27, 2024

Thank you @comphead! I should have done this myself. I guess depending on the terminal setup, the color scheme can be either smooth or not.

Thanks @trungda. I really love we started the coloring/customizing, appearance is what people buy :) and now we have all the code inside, and both users and developers can now experiment and come up with solution. It can even a factory of solutions, different schemas, etc

@alamb would you mind sharing your opinion?

I think this sounds like a great idea.

I would suggest filing a ticket explaining what is desired (namely come up with a color scheme that is pleasing, maybe even enough to enable by default) which may also help attract additional contributions

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM -- thanks @comphead -- I do think it would be great to get to the point where this could be enabled by default for colorized terminals

@@ -136,6 +136,9 @@ struct Args {
default_value = "40"
)]
maxrows: MaxRows,

#[clap(long, help = "Enables console syntax highlighting")]
color: bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another potential option might be to follow the duckdb lead and call it ascii output mode 🤔 (when there is no color)

andrewlamb@Andrews-MacBook-Pro:~/Software/influxdb_iox$ duckdb --help
Usage: duckdb [OPTIONS] FILENAME [SQL]
FILENAME is the name of an DuckDB database. A new database is created
if the file does not previously exist.
OPTIONS include:
   -append              append the database to the end of the file
   -ascii               set output mode to 'ascii'
   -bail                stop after hitting an error
   -batch               force batch I/O
   -box                 set output mode to 'box'
   -column              set output mode to 'column'
   -cmd COMMAND         run "COMMAND" before reading stdin
   -c COMMAND           run "COMMAND" and exit
   -csv                 set output mode to 'csv'
   -echo                print commands before execution
   -init FILENAME       read/process named file
   -[no]header          turn headers on or off
   -help                show this message
   -html                set output mode to HTML
   -interactive         force interactive I/O
   -json                set output mode to 'json'
   -line                set output mode to 'line'
   -list                set output mode to 'list'
   -markdown            set output mode to 'markdown'
   -newline SEP         set output row separator. Default: '\n'
   -nofollow            refuse to open symbolic links to database files
   -no-stdin            exit after processing options instead of reading stdin
   -nullvalue TEXT      set text string for NULL values. Default ''
   -quote               set output mode to 'quote'
   -readonly            open the database read-only
   -s COMMAND           run "COMMAND" and exit
   -separator SEP       set output column separator. Default: '|'
   -stats               print memory stats before each finalize
   -table               set output mode to 'table'
   -unsigned            allow loading of unsigned extensions
   -version             show DuckDB version

@comphead
Copy link
Contributor Author

I also like duckdb style its not overcolored and easy to read, but yes we can implement now different highlighters.

@comphead comphead merged commit ff7dfc3 into apache:main Jan 27, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants