engineer-man / piston-bot

I Run Code bot on Discord
https://emkc.org/run
MIT License
239 stars 35 forks source link

Add automatic boilerplate code for other languages #3

Open brtwrst opened 4 years ago

brtwrst commented 4 years ago

We have automatic boilerplate code for java snippets but there are other languages that could use this functionality as well.

Identify a language that requires some boilerplate code added every time and extend the codeswap.py file with automatic boilerplate for that language if it is not already present in the entered code.

Example: when you want to run C code like this:

#include <stdio.h>
printf("hello word!");

it will not work because it needs main() {} make it so that it is automatically added and the code will be interpreted as

#include <stdio.h>
int main() {
  printf("hello word!");
}
brtwrst commented 4 years ago

Rust boilerplate was added by @UsairimIsani

brtwrst commented 3 years ago

Boilerplate code now exists for

brainplot commented 3 years ago

Can I work on this? What are the files I should look at where this feature is implemented?

brtwrst commented 3 years ago

What languages do you think can benefit from boilerplate code?

The replacement happens here: https://github.com/engineer-man/piston-bot/blob/master/src/cogs/utils/codeswap.py

brainplot commented 3 years ago

I had a look at the list of supported languages and I have to admit, a good part of them I do not know. However, from the ones I do know, I think Kotlin could benefit from the same treatment as Java snippets and PHP may have the <?php ... ?> thing automatically added, if absent. Besides of course C and C++, which were discussed in this issue.

What do you think?

brtwrst commented 3 years ago

C and CPP is already there.

Feel free to add anything you think will help - Kotlin seems like a good candidate.

brainplot commented 3 years ago

C and CPP is already there.

I would like to add the automatic addition of #include/import directives (depending on the language). This issue states it's still a missing feature. Was it added and this issue is no longer relevant or is it still a missing feature?

Brikaa commented 2 years ago

Basic and Fsharp.net would need to be added