Skip to content

Commit

Permalink
feat: refactor vyper cli
Browse files Browse the repository at this point in the history
  • Loading branch information
hhamud committed Jul 31, 2023
1 parent c4b52e2 commit b0d99b5
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 11 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Test

on:
push:
branches:
- main
pull_request:
branches:
- "**"

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [macos-latest, ubuntu-latest]
needs: install
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Run the test script
run: |
curl -sSL "https://raw.githubusercontent.com/hhamud/dasy/main/scripts/test.sh" | bash
1 change: 0 additions & 1 deletion dasy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import hy
from hy import read, read_many
from dasy.compiler import compile, compile_file
from dasy.main import main
from dasy.parser.output import get_external_interface
from .parser import parse
from .parser.parse import parse_src, parse_node
Expand Down
3 changes: 1 addition & 2 deletions dasy/cli/vyper.py → dasy/cli/notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@

@click.command(
help="Lispy Smart Contract Language for the EVM",
context_settings=dict(help_option_names=["-h", "--help"]),
width=120,
)
@click.argument("filename", type=click.Path(exists=True), default="")
@click.option("-f", "--format", help=format_help, default="bytecode")
Expand Down
22 changes: 15 additions & 7 deletions dasy/cli/vyper.hy
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
(import sys)
(import click)
(import dasy [compiler parser])
(import vyper.compiler [OUTPUT_FORMATS as VYPER_OUTPUT_FORMATS])
(import vyper.compiler [OUTPUT_FORMATS :as VYPER_OUTPUT_FORMATS])
(import dasy.parser.output [get_external_interface])



(setv format_help = """
(setv format-help
"
Format to print, one or more of:
bytecode (default) - Deployable bytecode
bytecode_runtime - Bytecode at runtime
Expand All @@ -27,12 +28,19 @@ ir - Intermediate representation in list format
ir_json - Intermediate representation in JSON format
hex-ir - Output IR and assembly constants in hex instead of decimal
no-optimize - Do not optimize (don't use this for production code)
""")
")

(setv OUTPUT_FORMATS (VYPER_OUTPUT_FORMATS.copy))
(setv )
(setv (get OUTPUT_FORMATS "vyper_interface") (get OUTPUT_FORMATS "external_interface"))
(setv (get OUTPUT_FORMATS "external_interface") get_external_interface)

(defn
[click.command :help "Lispy Smart Contract Language for the EVM"
(click.option "-f" "--format" :help format-help :default "bytecode")]
main [filename format]
(print "hello world")
)

OUTPUT_FORMATS = VYPER_OUTPUT_FORMATS.copy()
OUTPUT_FORMATS["vyper_interface"] = OUTPUT_FORMATS["external_interface"]
OUTPUT_FORMATS["external_interface"] = get_external_interface


(when (= __name__ "__main__") (main))
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
"dasy" = "dasy:main"
"dasy" = "dasy.cli.vyper:cli"



[tool.pytest.ini_options]
filterwarnings = [
Expand Down

0 comments on commit b0d99b5

Please sign in to comment.