Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add formats to help for command line #1056

Closed
wants to merge 4 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions bin/vyper
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,6 @@ from vyper.parser.parser import parse_to_lll
from vyper.parser import parser_utils
from vyper import compile_lll

warnings.simplefilter('always')
sys.tracebacklimit = 0
tb_limit = os.environ.get('VYPER_TRACEBACK_LIMIT')
if tb_limit:
sys.tracebacklimit = int(tb_limit)

parser = argparse.ArgumentParser(description='Vyper programming language for Ethereum')
parser.add_argument('--version', action='version', version='{0}'.format(vyper.__version__))
parser.add_argument('input_file', help='Vyper sourcecode to compile')
parser.add_argument('-f', help='Format to print', default='bytecode', dest='format')
parser.add_argument('--show-gas-estimates', help='Show gas estimates in ir output mode.', action="store_true")

args = parser.parse_args()


def uniq(seq):
exists = set()
Expand Down Expand Up @@ -78,6 +64,13 @@ def get_source_map_asm_list(code):


if __name__ == '__main__':

warnings.simplefilter('always')
sys.tracebacklimit = 0
tb_limit = os.environ.get('VYPER_TRACEBACK_LIMIT')
if tb_limit:
sys.tracebacklimit = int(tb_limit)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering these are used in a global scope, I think having them outside main might make sense?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. This script is not meant to be used as a library right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, these are all related to CLI usage ;)



output_format = {}
output_format['abi_python'] = lambda code: compiler.mk_full_signature(code)
Expand All @@ -90,6 +83,14 @@ if __name__ == '__main__':
output_format['source_map'] = get_source_map
output_format['source_map_asm_list'] = get_source_map_asm_list

parser = argparse.ArgumentParser(description='Vyper programming language for Ethereum')
parser.add_argument('--version', action='version', version='{0}'.format(vyper.__version__))
parser.add_argument('input_file', help='Vyper sourcecode to compile')
parser.add_argument('-f', help='Format to print. Options: {}'.format(', '.join(output_format.keys())), default='bytecode', dest='format')
parser.add_argument('--show-gas-estimates', help='Show gas estimates in ir output mode.', action="store_true")

args = parser.parse_args()

with open(args.input_file) as fh:
code = fh.read()

Expand Down