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

Use colors for some output messages #207

Merged
merged 6 commits into from Jul 7, 2019
Merged

Use colors for some output messages #207

merged 6 commits into from Jul 7, 2019

Conversation

andreynering
Copy link
Member

@andreynering andreynering commented May 26, 2019

This makes identifying specific types of messages easier.

  • Green: commands
  • Yellow: waning messages
  • Red: error messages
  • Magenta: debug information
  • Etc

Output from commands will be kept untouched.

TODO:

  • Add --color=false flag to disable this
  • Disable color for version < 3
  • Prettify task --list(skipping for now: tabwriter don't play nicely with colors)?

Screen Shot 2019-05-26 at 6 41 57 PM

Screen Shot 2019-05-26 at 6 42 34 PM

Screen Shot 2019-05-26 at 6 43 09 PM

@andreynering andreynering added this to the v3 milestone May 26, 2019
@andreynering andreynering mentioned this pull request May 26, 2019
18 tasks
@stephenprater
Copy link
Contributor

stephenprater commented May 29, 2019

I'd like to see the colors exposed in Templater so that you we can control color in echoed strings. For instance, we have a task that does this:

<snip>
cmds:
  - echo "$(tput setaf 1) Press Ctrl-C now to cancel the deploy!"
  - sleep 5
  - task: deploy

It would be nice to expose the colors as format functions so you could do something similar to this:

  - echo "{{.RED}} Press Ctrl-C {{.BOLD}}NOW{{.DEFAULT}} to cancel the deploy"

@andreynering
Copy link
Member Author

@stephenprater I think I'd prefer to have a different flag instead:

print:
  cmds:
    - cmd: echo "Something"
      color: red

This wouldn't solve the use case of having different colors on the same command, though.

@stephenprater
Copy link
Contributor

Hmm - that's good point. Our use case was actually for the prefix string so it's easier to differentiate between tasks.

tasks:
   red_task:
      prefix: '{{.RED}} RED'
      cmds:
         - echo "something"

output would be like

[ RED ] something

Where "RED" is in red.

But the more that I think about it, the less I want to expose a plethora of special variables. Maybe a function that does something like: {{ color('red') }} instead?

@andreynering
Copy link
Member Author

@stephenprater Yeah, we need to mature that idea first.

I gonna finish this PR at some point, and you're free to open another issue with a proposal if you come with a good one. 🙂

@andreynering andreynering merged commit e625508 into v3 Jul 7, 2019
@andreynering andreynering deleted the colored-output branch July 7, 2019 17:41
@wdscxsj
Copy link

wdscxsj commented May 25, 2020

Color not working on Windows with 3.0 preview 4?

@andreynering
Copy link
Member Author

@wdscxsj Have you changed your Taskfile from version: 2 to version: 3?

@wdscxsj
Copy link

wdscxsj commented Jun 1, 2020

@andreynering Sure. Here is the effect on my machine (Windows 10 64-bit):

task

@andreynering
Copy link
Member Author

@wdscxsj It may be a Windows-specific issue. Can you open another issue for tracking?

Also, does it also happens on v2?

@wdscxsj
Copy link

wdscxsj commented Jun 12, 2020

@andreynering Sure, please see #343.

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.

None yet

3 participants