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

Add colors to cli messages #11

Merged
merged 15 commits into from Oct 31, 2020
Merged

Add colors to cli messages #11

merged 15 commits into from Oct 31, 2020

Conversation

Zebralt
Copy link
Contributor

@Zebralt Zebralt commented Oct 16, 2020

Related issue: #5

Here's what this PR brings:

  • when an action is successful, print in green (Killed X, Scheduled X);
  • when an exception is raised, print in red + hide traceback for commonplace errors (file not found, unsupported platform, hickory specific errors);
  • the output of status isn't colored because as a table-like output, it's likely to be passed through a pipe for other purposes (although you could always detect when this happens using os.isatty and not add any colors).
  • added hickory/__main__.py to be able to run the package against a specific python runtime: python -m hickory targeting the folder or the installed package.

Coloring is done using colorama, a popular terminal coloring package. It also brings cross-compatibility with Windows since coloring is done through API calls rather than escape sequences in there.

@maxhumber
Copy link
Owner

Zebralt! Thanks for your contribution.

Unfortunately, hickory has an aversion to and does not want take on any third party dependencies (that's my bad, I should have made this clear in the issue)

Do you think we could rewrite the the colouring functions with something like this: https://stackoverflow.com/a/58149095/3731467?

Otherwise, the rest of the code fixes you've added are solid 👍

@Zebralt
Copy link
Contributor Author

Zebralt commented Oct 16, 2020

Yeah, I can do that. I'll just replace the colorama imports with custom ones.

If you ever want to bring colors to Windows though, colorama is probably your best bet since there's a whole part of the package that is dedicated to translate escape sequences into Windows calls. Not that I'm a Windows fanboy or anything of the like :P

@Zebralt
Copy link
Contributor Author

Zebralt commented Oct 19, 2020

@maxhumber
Hi, could you review my last changes ?
The main implementation is in colors.py.

@maxhumber maxhumber merged commit c164fdd into maxhumber:master Oct 31, 2020
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