piston-bot icon indicating copy to clipboard operation
piston-bot copied to clipboard

Add automatic boilerplate code for other languages

Open brtwrst opened this issue 4 years ago • 8 comments

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 avatar Jul 16 '20 10:07 brtwrst

Rust boilerplate was added by @UsairimIsani

brtwrst avatar Aug 04 '20 16:08 brtwrst

Boilerplate code now exists for

  • java
  • rust
  • cpp
  • go
  • csharp

brtwrst avatar Jan 26 '21 16:01 brtwrst

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

brainplot avatar Apr 24 '21 09:04 brainplot

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

brtwrst avatar Apr 24 '21 09:04 brtwrst

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?

brainplot avatar Apr 24 '21 09:04 brainplot

C and CPP is already there.

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

brtwrst avatar Apr 24 '21 09:04 brtwrst

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?

brainplot avatar Apr 24 '21 09:04 brainplot

Basic and Fsharp.net would need to be added

Brikaa avatar Oct 07 '21 11:10 Brikaa