scripts/hapy_cli.py
def run(filename, compile_only, save):
    """Execute Hapy files
	Can either
	1. Compile and return compiled code or
	2. Compile, execute and return output
	"""

    cwd = os.getcwd()
    compiled_python = ""

    click.secho(f'[i]: Compiling {filename.lstrip(".")}...\n', fg="green")

    # check if file ends in `.hapy` if not throw error!
    if not filename.endswith(".hapy"):
        raise click.ClickException("Not a Hapy file :/")

    with open(filename, "r") as file:
        hapy_code = file.read()
        compiled_python = transpile(hapy_code)

    # if user wants to save file!
    if save:
        new_filename = filename.rstrip(".hapy") + ".ha.py"
        click.secho("\n" + "[i]: Saved file as %s" % new_filename + "\n",
                    fg="green")
        with open(new_filename, "w") as py_file:
            py_file.write(compiled_python)

    if compile_only:
        # click.secho("Compiled code:\n", fg="green", underline=True)
        click.secho(compiled_python, bold=True)
    else:
        # execute the compiled code
        run2(compiled_python)
Execute Hapy files
	Can either
	1. Compile and return compiled code or
	2. Compile, execute and return output
	
Execute Hapy files
Can either
1. Compile and return compiled code or
2. Compile, execute and return output
Execute Hapy files Can either 1 . Compile and return compiled code or 2 . Compile execute and return output
def run(filename, compile_only, save):
    cwd = os.getcwd()
    compiled_python = ""
    click.secho(f'[i]: Compiling {filename.lstrip(".")}...\n', fg="green")
    if not filename.endswith(".hapy"):
        raise click.ClickException("Not a Hapy file :/")
    with open(filename, "r") as file:
        hapy_code = file.read()
        compiled_python = transpile(hapy_code)
    if save:
        new_filename = filename.rstrip(".hapy") + ".ha.py"
        click.secho("\n" + "[i]: Saved file as %s" % new_filename + "\n",
                    fg="green")
        with open(new_filename, "w") as py_file:
            py_file.write(compiled_python)
    if compile_only:
        click.secho(compiled_python, bold=True)
    else:
        run2(compiled_python)
def run ( filename , compile_only , save ) : cwd = os . getcwd ( ) compiled_python = "" click . secho ( f'[i]: Compiling {filename.lstrip(".")}...\n' , fg = "green" ) if not filename . endswith ( ".hapy" ) : raise click . ClickException ( "Not a Hapy file :/" ) with open ( filename , "r" ) as file : hapy_code = file . read ( ) compiled_python = transpile ( hapy_code ) if save : new_filename = filename . rstrip ( ".hapy" ) + ".ha.py" click . secho ( "\n" + "[i]: Saved file as %s" % new_filename + "\n" , fg = "green" ) with open ( new_filename , "w" ) as py_file : py_file . write ( compiled_python ) if compile_only : click . secho ( compiled_python , bold = True ) else : run2 ( compiled_python )
Execute Hapy files
Can either
1.
Execute Hapy files Can either 1 .
"""Execute Hapy files
	Can either
	1. Compile and return compiled code or
	2. Compile, execute and return output
	""" # check if file ends in `.hapy` if not throw error! # if user wants to save file! # click.secho("Compiled code:\n", fg="green", underline=True) # execute the compiled code
filename
compile_only
save