├── .gitignore ├── README.md ├── build.py ├── display.py └── langs ├── R_run.py ├── bash_run.py ├── c_family_run.py ├── d_run.py ├── dart_run.py ├── go_run.py ├── javascript_run.py ├── julia_run.py ├── lua_run.py ├── perl_run.py ├── python_run.py ├── qbasic_run.py ├── ruby_run.py ├── rust_run.py ├── sql_run.py ├── test.bash ├── v_run.py └── zsh_run.py /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__/ 2 | langs/__pycache__/ 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LAZY-BUILDER 2 | 3 | Lazy-Builder is a python script for buinding or running any programming language('s file) in vim by mapping lazy-builder script in vimrc(for vim), init.vim(for neo-vim) file. 4 | 5 | ### logic 6 | logic of lazy-build is simple. it just analyse the extension of file which you want to build/run.If programming language is Interpreted, it ran the file as interpreted language OR if programming language is Compiled, it ran the/build file as compliled language 7 | 8 | ## Uses 9 | 10 | 11 | ``` 12 | usage: python build.py [-h] [-r] [-b] [-br] [-o] program_name 13 | 14 | positional arguments: 15 | program_name File/Program that you want to RUN/BUILD (eg. hello.c, calculate.py, auto.sh) 16 | 17 | optional arguments: 18 | -h, --help show this help message and exit 19 | -r 0 or 1, 1 means RUN and 0(default) means don't RUN the program 20 | -b 0 or 1, 1 means BUILD and 0(default) means don't BUILD the program 21 | -br 0 or 1, 1 means BUILD and RUN and 0 means don't BUILD and RUN the program 22 | -o location for output of compiled language (eg. /home/user/folder1/) 23 | 24 | ``` 25 | 26 | ## Using with vim/neo-vim 27 | you can use lazy-build with vim by mapping as shown in below example: 28 | 29 | [ NOTE: first install [vim-floaterm](https://github.com/voldikss/vim-floaterm) plugin 30 | OR 31 | if you don't want to install vim-floaterm plugin, go with [this](https://github.com/shaeinst/lazy-builder/tree/main) branch and follow [this](https://github.com/shaeinst/lazy-builder/tree/main#using-with-vimneo-vim) example of mapping (which use builtin split option) 32 | ] 33 | ``` 34 | " Run program file when leader+r is pressed 35 | nnoremap r :w :FloatermNew 36 | \ python /home/user/folder/lazy-builder/build.py -o /home/user/.cache/build_files/ -r 1 % 37 | 38 | " build the program file when leader+b is pressed 39 | nnoremap b :w :FloatermNew 40 | \ time 41 | \ python /home/user/folder/lazy-builder/build.py -o /home/user/.cache/build_files/ -b 1 % 42 | 43 | " build and then run the program when leader+o is pressed 44 | nnoremap o :w :FloatermNew 45 | \ time 46 | \ python /home/user/folder/lazy-builder/build.py -o /home/user/.cache/build_files/ -br 1 % 47 | ``` 48 | replace the following location to the location where you downloaded/cloned lazy-builder repositories 49 | ``` 50 | /home/user/folder/lazy-builder/build.py 51 | ``` 52 | replace this location to your desired location where you want to put the output/build/compiled files. 53 | ``` 54 | /home/user/.cache/build_files/ 55 | ``` 56 | or if you want the compiled file to stay in it's parent directory(from where it's compiled) then remove "-o /home/user/.cache/build_files/" from binding 57 | 58 | 59 | 60 | # currently supported languages 61 | ``` 62 | [ Compiled Languages ] 63 | c/c++ 64 | D 65 | go 66 | qbasic 67 | rust 68 | V 69 | 70 | [ Interpreted Languages ] 71 | bash 72 | javascript 73 | julia 74 | perl 75 | python 76 | R 77 | sql 78 | zsh 79 | 80 | [ more comming soon...] 81 | ``` 82 | # to-do 83 | add more language support 84 | 85 | ## Screenshots 86 | ### running python program 87 | ![running python file using lazy-builder script](https://github.com/shaeinst/media/raw/main/images/github-repositories/lazy-builder/running_python_program.png) 88 | 89 | ### compiling c++ program 90 | ![running python file using lazy-builder script](https://github.com/shaeinst/media/raw/main/images/github-repositories/lazy-builder/comiling.png) 91 | 92 | ### running c++ program 93 | ![running python file using lazy-builder script](https://github.com/shaeinst/media/raw/main/images/github-repositories/lazy-builder/running_c%2B%2B_program.png) 94 | 95 | ### compiling and then running c++ program 96 | ![running python file using lazy-builder script](https://github.com/shaeinst/media/raw/main/images/github-repositories/lazy-builder/compile_and_running.png) 97 | -------------------------------------------------------------------------------- /build.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python3 2 | 3 | # ---------------------------------------------------------------------------- 4 | # import important module 5 | import argparse 6 | import re # regular expression for recognizing file 7 | from pathlib import Path # required for path 8 | # ---------------------------------------------------------------------------- 9 | 10 | 11 | 12 | # ---------------------------------------------------------------------------- 13 | parser = argparse.ArgumentParser() 14 | # for Run the program 15 | parser.add_argument("-r", type=int, default=0, 16 | help="0 or 1, 1 means RUN and 0(default) means don't RUN the program") 17 | # for Build the program 18 | parser.add_argument("-b", type=int, default=0, 19 | help="0 or 1, 1 means BUILD and 0(default) means don't BUILD the program") 20 | # for Build and Run the program 21 | parser.add_argument("-br", type=int, default=0, 22 | help="0 or 1, 1 means BUILD and RUN and 0 means don't BUILD and RUN the program") 23 | # for Output/compiled file to specific location we want 24 | parser.add_argument("-o", type=str, 25 | help='location for output of compiled language (eg. /home/user/folder1/)') 26 | # Program/file Name(which we want to build/run) 27 | parser.add_argument("program_name", metavar='program_name', 28 | help='File/Program that you want to RUN/BUILD (eg. hello.c, calculate.py, auto.sh)') 29 | # ---------------------------------------------------------------------------- 30 | 31 | 32 | # ---------------------------------------------------------------------------- 33 | args = parser.parse_args() 34 | program_name = args.program_name 35 | run = args.r 36 | build = args.b 37 | build_run = args.br 38 | parent_dir = Path(__file__).parent.absolute() 39 | program_dir = Path.cwd() 40 | output_location = args.o 41 | program_name_no_loc = program_name.split("/")[-1] 42 | program_name_safe = f"{program_dir}/{program_name_no_loc}" 43 | # ---------------------------------------------------------------------------- 44 | 45 | 46 | 47 | # ---------------------------------------------------------------------------- 48 | def analyse_program_extension(file_name): 49 | """ Analyse Program Name """ 50 | file_extension = re.split('\.', file_name) 51 | 52 | if len(file_extension) == 1 or file_extension[-1] == '': 53 | return 0 54 | # returning extension name (eg. from file hello.py, py will be returned ) 55 | return file_extension[-1] 56 | program_extension = analyse_program_extension(program_name) 57 | # ---------------------------------------------------------------------------- 58 | compiled_langs = ["c", "C", "cpp", "c++", "cxx", "v", "go", "bas", "rs", "d"] 59 | interpreted_langs = ["bash", "jl", "js", "lua", "pl", "py", "r", "rb", "sh", "sql", "zsh", "dart"] 60 | 61 | # ---------------------------------------------------------------------------- 62 | interpreted_language = 0 63 | compiled_language = 0 64 | 65 | if str(program_extension) in compiled_langs: 66 | compiled_language = 1 67 | if str(program_extension) in interpreted_langs: 68 | interpreted_language = 1 69 | # ---------------------------------------------------------------------------- 70 | 71 | 72 | 73 | # ---------------------------------------------------------------------------- 74 | # ---------------------------------------------------------------------------- 75 | #for interpreted language 76 | if interpreted_language and build == 1 or interpreted_language and build_run == 1: 77 | print("Interpreted Language can't compiled") 78 | if interpreted_language and run == 1: 79 | if program_extension == "py": 80 | from langs.python_run import python_run 81 | python_run(program_name) 82 | 83 | if program_extension in ["bash", "sh"]: 84 | from langs.bash_run import bash_run 85 | bash_run(program_name) 86 | 87 | if program_extension == "zsh": 88 | from langs.zsh_run import zsh_run 89 | zsh_run(program_name) 90 | 91 | if program_extension == "pl": 92 | from langs.perl_run import perl_run 93 | perl_run(program_name) 94 | 95 | if program_extension == "js": 96 | from langs.javascript_run import javascript_run 97 | javascript_run(program_name) 98 | 99 | if program_extension == "rb": 100 | from langs.ruby_run import ruby_run 101 | ruby_run(program_name) 102 | 103 | if program_extension == "jl": 104 | from langs.julia_run import julia_run 105 | julia_run(program_name) 106 | 107 | if program_extension == "r": 108 | from langs.R_run import R_run 109 | R_run(program_name) 110 | 111 | if program_extension == "dart": 112 | from langs.dart_run import dart_run 113 | dart_run(program_name) 114 | 115 | if program_extension == "sql": 116 | db_conf_file = str(Path.home())+"/.my.cnf" 117 | if Path(db_conf_file).is_file(): 118 | from langs.sql_run import sql_run 119 | sql_run(program_name) 120 | print(program_name) 121 | else: 122 | print("please configure ~/.sql_conf file \n") 123 | import sys; sys.exit() 124 | 125 | 126 | #for compiled_language language 127 | # build compiled language 128 | if compiled_language: 129 | if program_extension in ["c", "c++", "cpp", "C", "cxx"]: 130 | from langs.c_family_run import c_family_run 131 | c_family_run(program_name_safe, [build, run, build_run], output_location) 132 | 133 | if program_extension == "d": 134 | from langs.d_run import d_run 135 | d_run(program_name_safe, [build, run, build_run], output_location) 136 | 137 | if program_extension == "rs": 138 | from langs.rust_run import rust_run 139 | rust_run(program_name_safe, [build, run, build_run], output_location) 140 | 141 | if program_extension == "v": 142 | from langs.v_run import v_run 143 | v_run(program_name_safe, [build, run, build_run], output_location) 144 | 145 | if program_extension == "go": 146 | from langs.go_run import go_run 147 | go_run(program_name_safe, [build, run, build_run], output_location) 148 | 149 | if program_extension == "bas": 150 | from langs.qbasic_run import qbasic_run 151 | qbasic_run(program_name_safe, [build, run, build_run], output_location) 152 | # ---------------------------------------------------------------------------- 153 | # ---------------------------------------------------------------------------- 154 | -------------------------------------------------------------------------------- /display.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | # colors 5 | RESET = "\033[0m" 6 | BLACK = "\033[0;30;0m" 7 | GREEN = "\033[0;32m" 8 | RED = "\033[0;31;47m" 9 | 10 | cols, rows = os.get_terminal_size() 11 | 12 | 13 | def print_das(): 14 | for _ in range(cols): 15 | print(f"{BLACK}─{RESET}", end='') 16 | print("") 17 | 18 | 19 | def print_run(): 20 | xx = "Running Program" 21 | xx = xx.center(int(cols)) 22 | print(xx) 23 | print_das() 24 | 25 | 26 | def sucess_msg(): 27 | xx = f" Compilation {GREEN}Successful ✔{RESET}" 28 | xx = xx.center(int(cols)) 29 | print_das() 30 | print(xx) 31 | print_das() 32 | 33 | 34 | def failed_msg(): 35 | xx = f" Compilation {RED}Failed ❌{RESET}" 36 | xx = xx.center(int(cols)) 37 | print_das() 38 | print(xx) 39 | print_das() 40 | -------------------------------------------------------------------------------- /langs/R_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | def R_run(file_name): 5 | cmd = f"Rscript {file_name}" 6 | cmd = "".join(cmd).split() 7 | display.print_run() 8 | subprocess.run(cmd) 9 | 10 | -------------------------------------------------------------------------------- /langs/bash_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | 3 | def bash_run(file_name): 4 | cmd = f"bash {file_name}" 5 | cmd = "".join(cmd).split() 6 | subprocess.run(cmd) 7 | 8 | -------------------------------------------------------------------------------- /langs/c_family_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | 5 | def c_family_exec(): 6 | cmd = f"{file_name_no_extc_with_loc}" 7 | if output_location != "None": 8 | cmd = f"{output_location}{file_name_no_extc}" 9 | cmd = "".join(cmd).split() 10 | 11 | try: 12 | display.print_run() 13 | subprocess.run(cmd) 14 | print("\n\n") 15 | except FileNotFoundError: 16 | print(f"compiled file, {file_name_no_extc_with_loc}, \033[91mnot found") 17 | 18 | 19 | def c_family_build(): 20 | cmd = f"gcc -Wall -ggdb {file_name_with_location} -o {file_name_no_extc} -lstdc++ -lm -msse3 -fdiagnostics-generate-patch" 21 | if output_location != "None": 22 | cmd = f"gcc -Wall -ggdb {file_name_with_location} -o {output_location}{file_name_no_extc} -lstdc++ -lm -msse3 -fdiagnostics-generate-patch" 23 | cmd = "".join(cmd).split() 24 | 25 | status = subprocess.run(cmd) 26 | 27 | if status.returncode == 0: 28 | display.sucess_msg() 29 | if status.returncode != 0: 30 | display.failed_msg() 31 | exit(1) 32 | 33 | 34 | def c_family_buildexec(): 35 | c_family_build() 36 | c_family_exec() 37 | 38 | 39 | def c_family_run(program_name, conditions, output_loc="None"): 40 | build, run, build_run = conditions 41 | global file_name, file_name_no_extc, output_location, file_name_with_location, file_name_no_extc_with_loc 42 | file_name = program_name.split("/")[-1] 43 | file_name_no_extc = file_name.split(".")[0] # getting rid of extension 44 | file_name_no_extc_with_loc = program_name.split(".")[0] 45 | file_name_with_location = program_name 46 | output_location = str(output_loc) 47 | 48 | if run == 1 and build == 0: 49 | c_family_exec() 50 | if run == 1 and build == 1: 51 | c_family_buildexec() 52 | if build == 1 and run == 0: 53 | c_family_build() 54 | if build_run == 1: 55 | c_family_buildexec() 56 | 57 | -------------------------------------------------------------------------------- /langs/d_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | 5 | def d_exec(): 6 | cmd = f"{file_name_no_extc_with_loc}" 7 | if output_location != "None": 8 | cmd = f"{output_location}{file_name_no_extc}" 9 | cmd = "".join(cmd).split() 10 | 11 | try: 12 | 13 | display.print_run() 14 | subprocess.run(cmd) 15 | print("\n\n") 16 | except FileNotFoundError: 17 | print(f"compiled file, {file_name_no_extc_with_loc}, \033[91mnot found") 18 | 19 | 20 | def d_build(): 21 | cmd = f"dmd {file_name_with_location} -of={file_name_no_extc}" 22 | if output_location != "None": 23 | cmd = f"dmd {file_name_with_location} -of={output_location}{file_name_no_extc}" 24 | cmd = "".join(cmd).split() 25 | 26 | status = subprocess.run(cmd) 27 | 28 | if status.returncode == 0: 29 | display.sucess_msg() 30 | if status.returncode != 0: 31 | display.failed_msg() 32 | exit(1) 33 | 34 | 35 | def d_buildexec(): 36 | d_build() 37 | d_exec() 38 | 39 | 40 | def d_run(program_name, conditions, output_loc="None"): 41 | build, run, build_run = conditions 42 | global file_name, file_name_no_extc, output_location, file_name_with_location, file_name_no_extc_with_loc 43 | file_name = program_name.split("/")[-1] 44 | file_name_no_extc = file_name.split(".")[0] # getting rid of extension 45 | file_name_no_extc_with_loc = program_name.split(".")[0] 46 | file_name_with_location = program_name 47 | output_location = str(output_loc) 48 | 49 | if run == 1 and build == 0: 50 | d_exec() 51 | if run == 1 and build == 1: 52 | d_buildexec() 53 | if build == 1 and run == 0: 54 | d_build() 55 | if build_run == 1: 56 | d_buildexec() 57 | 58 | -------------------------------------------------------------------------------- /langs/dart_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | 5 | def dart_run(file_name): 6 | cmd = f"dart {file_name}" 7 | cmd = "".join(cmd).split() 8 | display.print_run() 9 | subprocess.run(cmd) 10 | -------------------------------------------------------------------------------- /langs/go_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | 5 | def go_exec(): 6 | cmd = f"{file_name_no_extc_with_loc}" 7 | if output_location != "None": 8 | cmd = f"{output_location}{file_name_no_extc}" 9 | cmd = "".join(cmd).split() 10 | 11 | try: 12 | display.print_run() 13 | subprocess.run(cmd) 14 | print("\n\n") 15 | except FileNotFoundError: 16 | print(f"compiled file, {file_name_no_extc_with_loc}, \033[91mnot found") 17 | 18 | def go_build(): 19 | cmd = f"go build -o {file_name_no_extc} {file_name_with_location}" 20 | if output_location != "None": 21 | cmd = f"go build -o {output_location}{file_name_no_extc} {file_name_with_location}" 22 | cmd = "".join(cmd).split() 23 | 24 | status = subprocess.run(cmd) 25 | 26 | if status.returncode == 0: 27 | display.sucess_msg() 28 | if status.returncode != 0: 29 | display.failed_msg() 30 | exit(1) 31 | 32 | 33 | def go_buildexec(): 34 | go_build() 35 | go_exec() 36 | 37 | 38 | def go_run(program_name, conditions, output_loc="None"): 39 | build, run, build_run = conditions 40 | global file_name, file_name_no_extc, output_location, file_name_with_location, file_name_no_extc_with_loc 41 | file_name = program_name.split("/")[-1] 42 | file_name_no_extc = file_name.split(".")[0] # getting rid of extension 43 | file_name_no_extc_with_loc = program_name.split(".")[0] 44 | file_name_with_location = program_name 45 | output_location = str(output_loc) 46 | 47 | if run == 1 and build == 0: 48 | go_exec() 49 | if run == 1 and build == 1: 50 | go_buildexec() 51 | if build == 1 and run == 0: 52 | go_build() 53 | if build_run == 1: 54 | go_buildexec() 55 | 56 | -------------------------------------------------------------------------------- /langs/javascript_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | 3 | def javascript_run(file_name): 4 | cmd = f"node {file_name}" 5 | cmd = "".join(cmd).split() 6 | subprocess.run(cmd) 7 | 8 | -------------------------------------------------------------------------------- /langs/julia_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | def julia_run(file_name): 5 | cmd = f"julia {file_name}" 6 | cmd = "".join(cmd).split() 7 | display.print_run() 8 | subprocess.run(cmd) 9 | 10 | -------------------------------------------------------------------------------- /langs/lua_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | 5 | def lua_run(file_name): 6 | cmd = f"lua {file_name}" 7 | cmd = "".join(cmd).split() 8 | display.print_run() 9 | subprocess.run(cmd) 10 | -------------------------------------------------------------------------------- /langs/perl_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | 5 | def perl_run(file_name): 6 | cmd = f"perl {file_name}" 7 | cmd = "".join(cmd).split() 8 | display.print_run() 9 | subprocess.run(cmd) 10 | -------------------------------------------------------------------------------- /langs/python_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | 5 | def python_run(file_name): 6 | cmd = f"python {file_name}" 7 | cmd = "".join(cmd).split() 8 | display.print_run() 9 | subprocess.run(cmd) 10 | -------------------------------------------------------------------------------- /langs/qbasic_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | 3 | 4 | def qbasic_exec(): 5 | cmd = f"{file_name_no_extc_with_loc}" 6 | if output_location != "None": 7 | cmd = f"{output_location}{file_name_no_extc}" 8 | cmd = "".join(cmd).split() 9 | 10 | try: 11 | 12 | print("████████████████ RUNNING PROGRAM ████████████████") 13 | subprocess.run(cmd) 14 | print("\n\n") 15 | except FileNotFoundError: 16 | print(f"compiled file, {file_name_no_extc_with_loc}, \033[91mnot found") 17 | 18 | 19 | def qbasic_build(): 20 | cmd = f"/home/lazy/codeDNA/confiFILES/programmingLANGUAGE/qb64/qb64 -x {file_name_with_location} -o {file_name_no_extc}" 21 | if output_location != "None": 22 | cmd = f"/home/lazy/codeDNA/confiFILES/programmingLANGUAGE/qb64/qb64 -x {file_name_with_location} -o {output_location}{file_name_no_extc}" 23 | cmd = "".join(cmd).split() 24 | 25 | status = subprocess.run(cmd) 26 | 27 | if status.returncode == 0: 28 | print("__________________________________________") 29 | print("✔\tCompilation Successful") 30 | print("__________________________________________") 31 | if status.returncode != 0: 32 | print("__________________________________________") 33 | print("❌\tCompilation Failed") 34 | print("__________________________________________") 35 | exit(1) 36 | 37 | 38 | def qbasic_buildexec(): 39 | qbasic_build() 40 | qbasic_exec() 41 | 42 | 43 | def qbasic_run(program_name, conditions, output_loc="None"): 44 | build, run, build_run = conditions 45 | global file_name, file_name_no_extc, output_location, file_name_with_location, file_name_no_extc_with_loc 46 | file_name = program_name.split("/")[-1] 47 | file_name_no_extc = file_name.split(".")[0] # getting rid of extension 48 | file_name_no_extc_with_loc = program_name.split(".")[0] 49 | file_name_with_location = program_name 50 | output_location = str(output_loc) 51 | 52 | if run == 1 and build == 0: 53 | qbasic_exec() 54 | if run == 1 and build == 1: 55 | qbasic_buildexec() 56 | if build == 1 and run == 0: 57 | qbasic_build() 58 | if build_run == 1: 59 | qbasic_buildexec() 60 | 61 | -------------------------------------------------------------------------------- /langs/ruby_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | 5 | def ruby_run(file_name): 6 | cmd = f"ruby {file_name}" 7 | cmd = "".join(cmd).split() 8 | display.print_run() 9 | subprocess.run(cmd) 10 | -------------------------------------------------------------------------------- /langs/rust_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | 5 | def rust_exec(): 6 | cmd = f"{file_name_no_extc_with_loc}" 7 | if output_location != "None": 8 | cmd = f"{output_location}{file_name_no_extc}" 9 | cmd = "".join(cmd).split() 10 | 11 | try: 12 | display.print_run() 13 | subprocess.run(cmd) 14 | print("\n\n") 15 | except FileNotFoundError: 16 | print(f"compiled file, {file_name_no_extc_with_loc}, \033[91mnot found") 17 | 18 | 19 | def rust_build(): 20 | cmd = f"rustc {file_name_with_location} -o {file_name_no_extc}" 21 | if output_location != "None": 22 | cmd = f"rustc {file_name_with_location} -o {output_location}{file_name_no_extc}" 23 | cmd = "".join(cmd).split() 24 | 25 | status = subprocess.run(cmd) 26 | 27 | if status.returncode == 0: 28 | display.sucess_msg() 29 | if status.returncode != 0: 30 | display.failed_msg() 31 | exit(1) 32 | 33 | 34 | def rust_buildexec(): 35 | rust_build() 36 | rust_exec() 37 | 38 | 39 | def rust_run(program_name, conditions, output_loc="None"): 40 | build, run, build_run = conditions 41 | global file_name, file_name_no_extc, output_location, file_name_with_location, file_name_no_extc_with_loc 42 | file_name = program_name.split("/")[-1] 43 | file_name_no_extc = file_name.split(".")[0] # getting rid of extension 44 | file_name_no_extc_with_loc = program_name.split(".")[0] 45 | file_name_with_location = program_name 46 | output_location = str(output_loc) 47 | 48 | if run == 1 and build == 0: 49 | rust_exec() 50 | if run == 1 and build == 1: 51 | rust_buildexec() 52 | if build == 1 and run == 0: 53 | rust_build() 54 | if build_run == 1: 55 | rust_buildexec() 56 | 57 | -------------------------------------------------------------------------------- /langs/sql_run.py: -------------------------------------------------------------------------------- 1 | import display 2 | ## NOT worked 3 | # import subprocess 4 | 5 | # def sql_run(file_name): 6 | # cmd = f"mysql < {file_name} --table " 7 | # cmd = "".join(cmd).split() 8 | # subprocess.run(cmd) 9 | 10 | import os 11 | 12 | 13 | def sql_run(file_name): 14 | cmd = f"mysql < {file_name} --table " 15 | display.print_run() 16 | os.system(cmd) 17 | -------------------------------------------------------------------------------- /langs/test.bash: -------------------------------------------------------------------------------- 1 | echo "wow this is zsh" 2 | -------------------------------------------------------------------------------- /langs/v_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | 5 | def v_exec(): 6 | cmd = f"{file_name_no_extc_with_loc}" 7 | if output_location != "None": 8 | cmd = f"{output_location}{file_name_no_extc}" 9 | cmd = "".join(cmd).split() 10 | 11 | try: 12 | display.print_run() 13 | subprocess.run(cmd) 14 | print("\n\n") 15 | except FileNotFoundError: 16 | print(f"compiled file, {file_name_no_extc_with_loc}, \033[91mnot found") 17 | 18 | 19 | def v_build(): 20 | cmd = f"v {file_name_with_location} -o {file_name_no_extc} " 21 | if output_location != "None": 22 | cmd = f"v {file_name_with_location} -o {output_location}{file_name_no_extc}" 23 | cmd = "".join(cmd).split() 24 | 25 | status = subprocess.run(cmd) 26 | 27 | if status.returncode == 0: 28 | display.sucess_msg() 29 | if status.returncode != 0: 30 | display.failed_msg() 31 | exit(1) 32 | 33 | 34 | def v_buildexec(): 35 | v_build() 36 | v_exec() 37 | 38 | 39 | def v_run(program_name, conditions, output_loc="None"): 40 | build, run, build_run = conditions 41 | global file_name, file_name_no_extc, output_location, file_name_with_location, file_name_no_extc_with_loc 42 | file_name = program_name.split("/")[-1] 43 | file_name_no_extc = file_name.split(".")[0] # getting rid of extension 44 | file_name_no_extc_with_loc = program_name.split(".")[0] 45 | file_name_with_location = program_name 46 | output_location = str(output_loc) 47 | 48 | if run == 1 and build == 0: 49 | v_exec() 50 | if run == 1 and build == 1: 51 | v_buildexec() 52 | if build == 1 and run == 0: 53 | v_build() 54 | if build_run == 1: 55 | v_buildexec() 56 | -------------------------------------------------------------------------------- /langs/zsh_run.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import display 3 | 4 | 5 | def zsh_run(file_name): 6 | cmd = f"zsh {file_name}" 7 | cmd = "".join(cmd).split() 8 | display.print_run() 9 | subprocess.run(cmd) 10 | --------------------------------------------------------------------------------