Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

List available languages #2

Open
FrankKair opened this issue Jul 12, 2018 · 4 comments
Open

List available languages #2

FrankKair opened this issue Jul 12, 2018 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@FrankKair
Copy link
Owner

FrankKair commented Jul 12, 2018

It would be nice to have a command to list the available languages and how should one call them, or even have some alias.

For example, to run C++, one has to call $ polyenv cpp-gcc test.cpp which is really non intuitive.

This is the json with all the available languages:
https://tio.run/languages.json

@FrankKair FrankKair added the enhancement New feature or request label Jul 12, 2018
@FrankKair FrankKair self-assigned this Jul 12, 2018
@FrankKair
Copy link
Owner Author

FrankKair commented Jul 22, 2018

def available_languages():
    import requests
    url = "https://tio.run/languages.json"
    response = requests.get(url)
    data = response.json()
    return [f"{data[key]['name']} {key}" for key, value in data.items()]


def search_languages(target):
    languages = available_languages()
    return [lang for lang in languages if target.lower() in lang.lower()]


for lang in search_languages('c++'):
    print(lang)

@FrankKair
Copy link
Owner Author

@williamjamir What do you think?
What about something like $ polyenv languages to print all the available languages (with the available_languages() function) and $ polyenv languages cpp to work like a | grep -i, to help users search for their desired language.

@williamjamir
Copy link
Collaborator

williamjamir commented Jul 25, 2018

I think polyenv languages is a good solution for this, I'm just concerned with how we would implement.

  1. We can use @click.group and have two different commands (therefore losing the "default calling")
  2. Keep the default invocation, but making all arguments as optional (including "languages") and enforcing by hand that if languages is None language and file_path should be passed

@williamjamir
Copy link
Collaborator

We can also show this list of "available language" when the class 'TioRequest' raises an exception about a wrong language type.

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

No branches or pull requests

2 participants