Skip to content

Commit

Permalink
Merge pull request #1 from BenMeehan/ben/adding-own-go-compiler
Browse files Browse the repository at this point in the history
Ben/adding own go compiler
  • Loading branch information
BenMeehan authored Jun 9, 2023
2 parents b9ec5aa + 97c87ae commit 0cf4834
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 34 deletions.
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,18 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how

## [Unreleased]

- Initial release
- Initial release

## [0.0.1]

- Compiling using CodeEX API

## [1.0.0] - 2023-06-09

### Added
- New custom online compiler
- New languages Rust and Golang

### Removed

- CodeEX API
56 changes: 34 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,50 @@
# Welcome to Code Online Extension
# Run Code Online VSCode Extension

Code Online is a free extension for Visual Studio Code which allows you to run your program completely online directly from your editor without the need for a compiler to be installed in the local machine.
**Run Code Online** is a Visual Studio Code extension that allows you to compile and run code from multiple programming languages using an online compiler API. It simplifies the process of code execution by sending your code to the API, capturing the output, and displaying it in the editor.

It is perfect if you want to try out a try language or quickly execute a program in VS Code without installing a compiler.
**NOTE** : *This extension does not supprot GUI apps.*

**NOTE:**
This extension does not support GUI apps.
![demo.gif](https://s11.gifyu.com/images/SurpE.gif)

## Supported Languages
C++, C, C#, Java, Python, Ruby, Kotlin, Swift

... more to be added soon.
Run Code Online currently supports the following programming languages:

- C++
- C
- Python
- Java
- Javascript
- Go
- Rust
- *more to be added soon...*

# How to use
## Features

Install the *Run Code Online* extension from VS Code Extension Marketplace.
- Supports multiple programming languages.
- Automatic language detection based on the file extension.
- Ability to provide custom inputs for code execution.
- Easy-to-use interface with a command and status bar integration.
- Saves the output in a separate file for reference.

![extension.png](https://i.ibb.co/jLHktgL/Screenshot-4.png)
## Installation

In the file you want to execute simply press ***Ctrl+Shift+p*** in your keyboard to open the command palette.
Now type ***run*** and press *enter*.
1. Launch Visual Studio Code.
2. Go to the Extensions view (Ctrl+Shift+X).
3. Search for "Run Code Online" and click **Install**.
4. Once installed, the extension is ready to use.

![demo.gif](https://s10.gifyu.com/images/Code-Online1.gif)
## Usage

Thats it!
1. Open a file with the code you want to run.
2. Optionally, create an `input.txt` file in the same directory to provide custom inputs.
3. Press `Ctrl+Shift+P` (or `Cmd+Shift+P` on macOS) to open the Command Palette.
4. Type "CodeOnline: run" and select the command.
5. The extension will compile the code and display the output in the editor.
6. Check the output file (`YOUR_FILE_NAME-output.txt`) for reference.

You can view the output of your program in the ***output.txt*** file in the same directory.
## Feedback and Support

## Providing custom input

If you wan't to provide custom input to your program, create a file named ***input.txt*** in the same directory and enter the input in that file.

![inputDemo.gif](https://s10.gifyu.com/images/Code-Online2.gif)

**Thanks to @Jaagrav for letting me use his [CodeX API](https://github.com/Jaagrav/CodeX)**
If you encounter any issues or have suggestions for improvement, please don't hesitate to open an issue on the `[email protected]`. Your feedback is valuable and appreciated.

**Enjoy coding with CodeOnline!**
19 changes: 11 additions & 8 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
const vscode = require('vscode');
const fs=require("fs");
var axios = require('axios');
const path=require('path')

// Supported Languages
var langs=["cpp","c","py","java","rb","cs","kt","swift"]
var langs=["cpp","c","py","java","js","go","rs"]

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
Expand All @@ -26,12 +27,12 @@ function activate(context) {
// The code you place here will be executed every time your command is executed

// Display a message box to the user
vscode.window.showInformationMessage('Running code in CodeX...');
vscode.window.showInformationMessage('Running code in online compiler...');

// Get the required file paths
var currentlyOpenFile = vscode.window.activeTextEditor?.document.uri.fsPath;
var inputFile = currentlyOpenFile.substring(0, currentlyOpenFile.lastIndexOf('\\'))+"\\input.txt";
var outputFile=currentlyOpenFile.substring(0, currentlyOpenFile.lastIndexOf('\\'))+"\\output.txt";
var inputFile = path.join(path.dirname(currentlyOpenFile), "input.txt");
let outputFile = currentlyOpenFile.substring(0, currentlyOpenFile.lastIndexOf('.')) + '-output.txt';

// Variable to store the code, language and custom inputs
var content={
Expand All @@ -58,10 +59,10 @@ function activate(context) {
// Convert the data to JSON
var data=JSON.stringify(content);

// Configuration for CodeX API
// Configuration for API
var config = {
method: 'post',
url: 'https://codexweb.netlify.app/.netlify/functions/enforceCode',
url: 'https://load-balancer-1l8h.onrender.com/compile',
headers: {
'Content-Type': 'application/json'
},
Expand All @@ -71,14 +72,16 @@ function activate(context) {
// Making an axios request to the API with the JSON content
axios(config)
.then(function (response) {
fs.writeFileSync(outputFile,response.data.output);
fs.writeFileSync(outputFile,response.data);
})
.catch(function (error) {
// Message to user
vscode.window.showInformationMessage(data);
fs.writeFileSync(outputFile,error);
});

// Message to user
vscode.window.showInformationMessage('Check the output.txt file...');
vscode.window.showInformationMessage('Check the ', outputFile ,'file...');

}
});
Expand Down
Binary file removed images/extension.png
Binary file not shown.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"publisher": "BenMeehan111",
"description": "Run code online directly from VSCode",
"icon": "images/layers.png",
"version": "0.0.1",
"version": "1.0.0",
"engines": {
"vscode": "^1.63.0"
},
Expand Down

0 comments on commit 0cf4834

Please sign in to comment.