List available languages
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
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)
@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.
I think polyenv languages is a good solution for this, I'm just concerned with how we would implement.
- We can use
@click.groupand have two different commands (therefore losing the "default calling") - Keep the default invocation, but making all arguments as optional (including "languages") and enforcing by hand that
if languages is Nonelanguageandfile_pathshould be passed
We can also show this list of "available language" when the class 'TioRequest' raises an exception about a wrong language type.