Skip to content

Commit

Permalink
feat: adds ape vyper flatten command
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeshultz committed Mar 14, 2024
1 parent dff651b commit b63aad7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ape_vyper/_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from pathlib import Path

import ape
import click
from ape.cli import ape_cli_context


@click.group
def cli():
"""`vyper` command group"""


@cli.command(short_help="Flatten select contract source files")
@ape_cli_context()
@click.argument("CONTRACT", type=click.Path(exists=True, resolve_path=True))
@click.argument("OUTFILE", type=click.Path(exists=False, resolve_path=True, writable=True))
def flatten(cli_ctx, contract: Path, outfile: Path):
"""
Flatten a contract into a single file.
"""
with Path(outfile).open("w") as fout:
content = ape.compilers.flatten_contract(
Path(contract), base_path=ape.project.contracts_folder
)
fout.write(str(content))
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
python_requires=">=3.8,<4",
extras_require=extras_require,
py_modules=["ape_vyper"],
entry_points={
"ape_cli_subcommands": [
"ape_vyper=ape_vyper._cli:cli",
],
},
license="Apache-2.0",
zip_safe=False,
keywords="ethereum",
Expand Down

0 comments on commit b63aad7

Please sign in to comment.