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

pass args to the script #1259

Merged
merged 6 commits into from
Oct 11, 2021
Merged
Changes from 4 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
10 changes: 7 additions & 3 deletions brownie/_cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
from brownie.utils import color
from brownie.utils.docopt import docopt

__doc__ = f"""Usage: brownie run <filename> [<function>] [options]
__doc__ = f"""Usage: brownie run <filename> [<function>] [<arg>...] [options]

Arguments:
<filename> The name of the script to run
[<function>] The function to call (default is main)
[<arg>] Extra argument to pass to the function. For kwargs, do "kwarg=value"
BlinkyStitt marked this conversation as resolved.
Show resolved Hide resolved

Options:
--network [name] Use a specific network (default {CONFIG.settings['networks']['default']})
Expand All @@ -31,7 +32,7 @@


def main():
args = docopt(__doc__)
args = docopt(__doc__, more_magic=True)
_update_argv_from_docopt(args)

active_project = None
Expand All @@ -47,7 +48,10 @@ def main():

try:
return_value, frame = run(
args["<filename>"], method_name=args["<function>"] or "main", _include_frame=True
args["<filename>"],
method_name=args["<function>"] or "main",
args=args["<arg>"],
_include_frame=True,
)
exit_code = 0
except Exception as e:
Expand Down