#game #cli #codingame #coding-game

app cg-local

Rust port of the original CG local app

2 releases

0.1.1 Feb 15, 2024
0.1.0 Feb 11, 2024

#59 in Games

27 downloads per month

MIT license

18KB
283 lines

cg-local

Rust implementation of local CG Local. A replacement of the Java App and works with the original extensions

Install

Bin

download the latest and run it

# linux
./path/to/cg-local [options] --target <TARGET>
# windows
.\path\to\cg-local.exe [options] --target <TARGET>

Cargo

cargo install cg-local

from source

git clone https://codeberg.org/Vulpesx/cg-local.git && cd cg-local
cargo install --path .

Usage

Usage: cg-local [OPTIONS] --target <TARGET>

Options:
  -b, --bind <BIND>
          Address to bind to, DO NOT CHANGE

          this is the port the original extensions connect to changing this will mean the original extions wont work this is to support other extensions if they exist

          [default: 127.0.0.1:53135]

  -t, --target <TARGET>
          Path to target file, doesnt have to exist

          cg-local will watch this file for changes and upload them to the extension and download from the extension if twoway or download

  -d, --download
          downloads the file immediately

          download the file on connection to extension

  -p, --play
          auto play on file upload

          sets the extension to when it receives new code to play the test cases

      --two-way
          two way synchronizing, you can use the IDE too

          when the extension detects changes in the browser side ide it will send them to cg-local, this will set cg-local to accept the changes and write them to the file, you may have to reload editor to see them locally

      --timeout <TIMEOUT>
          time to wait for browser extension (ms)

          the time cg-local waits for the extension to send something this cannot be zero, if zero it would wait forever but dont worry cg-local wont accept a zero

          [default: 500]

  -h, --help
          Print help (see a summary with '-h')

  -V, --version
          Print version

Examples

# Synchronize main.rs with the IDE, enable auto-play by default
cg-local -p -t main.rs

Status

done unless someone makes a new extension, then i might update it

Thanks to

jmerle for the orginal app and extensions as well as vtavernier for a rust port of the original app that allowed me to make my first version despite being very sleep deprived.

you might be pleased to know that my port is less than half the code of vtavernier's and without an ungodly amount of async. pls check if using async or a lib to do something is over kill, you do not need another thread to watch a file or that much async either.

License

MIT or the file

Dependencies

~2.5–3.5MB
~67K SLoC