A bash script to help practice competitive programming. When practicing problems I find myself spending way too much time creating a new project folder, adding all the necessary files, writing a makefile, etc.
- either unzip the code file into a directory you want to have this functionality in, or use git clone.
- run
chmod +x problem.py
To run this code, simple use ./problem.py problemname language
This will create a new folder called problemname, with files in it that are needed to develop a small, single file project in that language.
Additionally, it opens up the most relevant file in the default text editor.
By default, atom is the default text editor, and language support is proved for:
Creates a Main.java file and inserts:
public class Main{
public static void main(String[] args){
}
}
And adds a makefile with
Main.class: Main.java
javac Main.java
Creates a main.py file and inserts
print("hello, world!")
Creates a main.cpp file and inserts
#include <iostream>
int main(){
return 0;
}
And adds a makefile with
bin: main.cpp
gcc -std=c++11 -Wall -Wextra -pedantic -O2 -o bin main.cpp
Creates a main.c file and inserts
#include <stdio.h>
int main(){
}
And adds a makefile with
bin: main.c
cc -std=c99 -o bin main.c
Creates a main.sh file and inserts
#!/usr/bin/env bash
Although a decent amount of functionality is provided out of the box, It is very easy to add new languages.
All customization should be done in config.json. It uses the following syntax:
{
"default-app": "<default text editor>",
"languages": {
"<lang name 1>": "files 1",
"<lang name 2>": "files 2",
"..."
"<lang name n>": "files n"
}
}
Where each group of files follows the syntax:
[
"<file 1>",
"<file 2>",
"...",
"<file n>"
]
And each file:
{
"filename": "<name of file to be created>",
"contents": "<contents of file to be created>"
}
For example, to add haskell support you might add the following to your config.json:
{
"default-app": "...",
"languages": {
"...,"
"haskell": [
{
"filename": "main.hs",
"contents": "main = putStrLn \"hello, world\""
}
],
"..."
}
}