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

Feature Request - echo Colored Text #203

Closed
Hecatron opened this issue Oct 30, 2021 · 6 comments
Closed

Feature Request - echo Colored Text #203

Hecatron opened this issue Oct 30, 2021 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@Hecatron
Copy link

Feature Description

Would or is it possible to echo colored text within duckscript?
So far I've tried echoing \033[2;31;43m to change the terminal color without any luck

@sagiegurari
Copy link
Owner

awesome idea, question is how to make it simple to use

@Hecatron
Copy link
Author

I'm afraid I don't know much about the duckscript language
but I'd guess it'd involve adding wrappers around https://crates.io/crates/colored

I have been looking into rust-script as well as an alternative
but then run into this problem - fornwall/rust-script#23

@sagiegurari
Copy link
Owner

didn't mean how to implement, more like how to use.
for example, should it be a new command or reuse echo, how are colors provided in the input, so on...

@Hecatron
Copy link
Author

Maybe something a bit like

color_string_example = array ${styles.color_red} Hello ${styles.color_normal} World
echo color_string_example: ${color_string_example}

Not quite sure of the limits of the string concatenation within duckscript, you'd also have to consider combining multiple styles. I suspect the way colored works currently is by wrapping strings with a beginning and ending ansi characters or perhaps something else for windows to colour individual strings.

@sagiegurari sagiegurari added the enhancement New feature or request label Oct 31, 2021
@sagiegurari
Copy link
Owner

Added new print and println commands which support color, background color and styling.
You can see the docs at:

Example:

print --color red --background-color green --style italic --style bold my text
println --color blue --background-color bright_yellow more text

@Hecatron
Copy link
Author

Hecatron commented Nov 1, 2021

Thats very useful, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants