Skip to content
/ clin Public

A automated cli runner for handlig all type of language compilation and execution

bashmyhed/clin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clin: A Universal Compiler and Interpreter Wrapper

clin is a command-line tool that simplifies the process of compiling and running code across various programming languages. It intelligently detects the language based on the file extension and acts as a wrapper around the appropriate compiler or interpreter.

Key Features:

  • Automatic Language Detection: Runs the correct compiler or interpreter based on the input file's extension.
  • Universal -o Flag: Specifies the output path for compiled binaries.
  • Pass-through Flags: Unknown flags are directly passed to the underlying compiler or interpreter.
  • Default Execution: By default, clin compiles (if necessary) and runs the resulting binary located in a temporary OS-dependent directory (/tmp).
  • Customizable Behavior:
    • -o <path>: Specify the output path for the binary.
    • -ot <path>: Specify the output path but do not execute the binary.
    • -t: Do not execute the binary after compilation.

Supported Languages:

clin currently supports the following programming languages:

  • C (.c)
  • C++ (.cpp)
  • Python (.py)
  • Go (.go)
  • Zig (.zig)
  • Rust (.rs)
  • Java (.java)
  • Swift (.swift)
  • Fortran 90 (.f90)
  • Fortran 95 (.f95)
  • Fortran 77 (.f)
  • Fortran 2003 (.f03)
  • Fortran 2008 (.f08)
  • Fortran (other extensions) (.for)
  • Haskell (.hs)
  • Ruby (.rb)
  • Perl (.pl)
  • PHP (.php)
  • Lua (.lua)
  • JavaScript (.js)
  • TypeScript (.ts)

With clin, you can seamlessly compile and run your code without needing to remember the specific commands for each language.

Installations

Linux/macOS

  • Requires sudo privilages
curl https://raw.githubusercontent.com/bashmyhed/clin/refs/heads/main/scripts/install.sh | sudo bash

Windows

Follow these steps to install clin using the batch script provided in the repository:

1. Download the Installer Script

Click the link below to download the installer batch file:

Download install.bat

Tip: Right-click the link above and choose "Save link as..." to save it locally.

2. Run the Script as Administrator

After downloading:

  1. Right-click the install.bat file.
  2. Select "Run as administrator" from the context menu.
  3. Windows may show a SmartScreen warning about running the file.
    • Click More info
    • Then click Run anyway

This will open a PowerShell window and guide you through the installation steps.

Running as administrator is required to install the binary to C:\Program Files\clin and modify the system PATH.

3. Done

After installation:

  • The clin binary will be placed in C:\Program Files\clin\clin.exe
  • The folder will be added to your system PATH
  • Windows Defender will be configured to exclude the folder (if possible)

You may need to restart your terminal or PowerShell for the changes to take effect.

help

Usage: clin [options] <source-file> [build flags]

Options

  • -v or --version — print the clin version
  • -h or --help — Show this help message
  • --verbose — enable verbose output (useful for debugging)
  • -o <file> — Set the output binary file path
  • -ot <file> — Set the output path for the binary but do not run it after building
  • -t — do not run the binary after compilation (useful for not running Java classes)
  • --build — Everything after this option is considered build flags and will be passed directly to the underlying compiler or interpreter. This option is not strictly necessary but can be used for clarity.

Examples

  • clin -o bin/myapp test.c Compile test.c and save the executable as bin/myapp.
  • clin -ot bin/myapp hello.cpp Compile hello.cpp and save the executable as bin/myapp, but do not run it.
  • clin script.py Run the Python script script.py.
  • clin --build "-Wall -O2" mycode.c Compile mycode.c with the build flags -Wall and -O2. The output binary will be created in the default temporary location and run.
  • clin -u myscript.py --input data.txt --verbose -n 5 Run the Python script myscript.py, passing the arguments -u --input data.txt --verbose -n 5 directly to the interpreter.
  • clin myscript.py --build "-u --input data.txt --verbose -n 5" Run the Python script myscript.py, treating -u --input data.txt --verbose -n 5 as build flags passed to the interpreter. Note the quoting to treat them as a single argument to --build.

Issues

  • Does not support flags like -d in java and similar, it ll still work but you will get error during runtime use -t & -ot flag for such cases
  • compilers/interpreters for specific languages are hoardcoded. I will add support for clinrc file to solve that issue
  • No support for runtime arguments or flags, same with runner flags like flag for java somethin.class
  • Could be optimised for efficient logic.

About

A automated cli runner for handlig all type of language compilation and execution

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •