Skip to content

Use our own shell coloration helper#103

Merged
Morriar merged 2 commits intomasterfrom
at-remove-colorize
Oct 15, 2021
Merged

Use our own shell coloration helper#103
Morriar merged 2 commits intomasterfrom
at-remove-colorize

Conversation

@Morriar
Copy link
Contributor

@Morriar Morriar commented Oct 15, 2021

Implement our own coloration helper for shell display that is type-friendly.

Fixes #101.

Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
@Morriar Morriar requested a review from a team October 15, 2021 19:12
@Morriar Morriar self-assigned this Oct 15, 2021
def colorize(string, *color)
return string unless color?
string.colorize(color)
T.unsafe(self).set_color(string, *color)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using unsafe because of the splat 😢

sig { params(string: String, color: Spoom::Color).returns(String) }
def colorize(string, *color)
return string unless @colors
T.unsafe(self).set_color(string, *color)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using unsafe because of the splat 😢

# frozen_string_literal: true

module Spoom
class Color < T::Enum
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thinking about it, maybe I should nest this under CLI

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I'll keep the diff in this PR to a minimum and do some cleaning in the helpers in a subsequent one.

@Morriar Morriar merged commit e205ab9 into master Oct 15, 2021
@Morriar Morriar deleted the at-remove-colorize branch October 15, 2021 20:40
@shopify-shipit shopify-shipit bot temporarily deployed to production October 18, 2021 15:00 Inactive
@Morriar Morriar mentioned this pull request Nov 26, 2021
@shopify-shipit shopify-shipit bot temporarily deployed to production December 8, 2021 21:43 Inactive
@Morriar Morriar added the chore Chore task label Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Chore task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

colorize dependency is GPL-licensed

4 participants