Cloud-CV / evalai-cli

:cloud: :rocket: Official EvalAI Command Line Tool
https://cli.eval.ai
BSD 3-Clause "New" or "Revised" License
55 stars 63 forks source link

[enhancement] Use different color for command usage examples within messages #243

Open nikochiko opened 4 years ago

nikochiko commented 4 years ago

Current Behaviour:

When a command is to be shown in a message as a usage example, the current way is to use backticks (`) to enclose it. This is hard to read as the rest of the message is of the same color. current-message

Expected Behavior:

Use a different color for the commands and a different color for the rest of the message. This should be done by using a function to parse the string, fetch the substring within the backticks (`) and return a complete message as expected with the part in backticks being shown in a different color. That is: proposed-behaviour

As red, yellow, white and green are used for other types by convention, I think cyan (as shown above) can be a good choice.

ShubhamPandey28 commented 4 years ago

I would like to do this if you alllow.

ShubhamPandey28 commented 4 years ago

@nikochiko Is it okay if I make a new interface.py in evalai/util containing the parsed echo function or can you please suggest me the way it is wanted.

nikochiko commented 4 years ago

@ShubhamPandey28 I think these changes should go either along with or after the enhancements proposed in https://github.com/Cloud-CV/evalai-cli/issues/234 as this can make use of the additions proposed there. So it would be better if that issue is resolved first, and then we come to this.

For example, I was thinking of having a syntax like:

def error_style(message):  # from 234 !?
    return style(message, bold=True,  fg="red")

def command_style(command):  # from 234 !?
    return style(command, bold=True, fg="cyan")

def prettify_error_with_command(message):
    ## incorporate both above methods here ##

# Usage:
echo(prettify_error_with_command(MESSAGE))

The approach mentioned in issue#234 recommends directly echoing the messages, which would make it harder to use both side-by-side.

What do you think? @ShubhamPandey28 @takitsuse cc: @vkartik97 @RishabhJain2018

nikochiko commented 4 years ago

@ShubhamPandey28 Yes, you are on the right track. Both changes should be made in the same file like interface.py I think the mentors can help with the naming here. I was thinking formatting.py or text_styling.py. Something that can give a more clear idea of what we are trying to achieve here.

hkmatsumoto commented 4 years ago

For printing things in multiple colors, @nikochiko's edit on proposal #234 looks reasonable. Sounds good to me👍