# Adding arguments to scripts

**URL:** <https://discourse.mitmproxy.org/t/adding-arguments-to-scripts/818>\
**Category:** Uncategorized\
**Created:** [January 29, 2018, 4:23am UTC](https://discourse.mitmproxy.org/t/adding-arguments-to-scripts/818 "2018-01-29T04:23:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aniketpanjwani](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/aniketpanjwani/32/266_2.png) [@aniketpanjwani](https://discourse.mitmproxy.org/u/aniketpanjwani)\
**Post date:** [January 29, 2018, 4:23am UTC](https://discourse.mitmproxy.org/t/adding-arguments-to-scripts/818/1 "2018-01-29T04:23:33Z")

</div>

I’m new to mitmproxy, and I’m having some difficulty figuring out how to add arguments to scripts. It looks like in some previous commits of the documentation and examples folder, there was an example for adding arguments to scripts , but [the documentation](https://github.com/mitmproxy/mitmproxy/blob/master/docs/scripting/overview.rst) hasn’t had anything to say about handling arguments for at least the last 8 months. I’ve got a few questions.

1. Has something change significantly in the API so that arguments are no longer easily added to scripts?
2. If this is just a case of the documentation lagging behind development, would someone be able to provide a minimal example of a modification of [this script](https://github.com/mitmproxy/mitmproxy/blob/master/examples/simple/redirect_requests.py), but where example. com is instead an argument?

---

<div class="post-metadata">

**Author:** ![mhils](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/mhils/32/7_2.png) [@mhils](https://discourse.mitmproxy.org/u/mhils)\
**Post date:** [January 29, 2018, 4:00pm UTC](https://discourse.mitmproxy.org/t/adding-arguments-to-scripts/818/2 "2018-01-29T16:00:11Z")

</div>

Hi,

Assuming you are on master (and not 2.0.x), your script can register options: [https://github.com/mitmproxy/mitmproxy/blob/master/examples/simple/custom\_option.py](https://github.com/mitmproxy/mitmproxy/blob/master/examples/simple/custom_option.py). You can set options during startup using `--set`, or you can edit them from within mitmproxy in the options editor. Documentation for 3.0 is in the works 🙂

---

<div class="post-metadata">

**Author:** ![aniketpanjwani](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/aniketpanjwani/32/266_2.png) [@aniketpanjwani](https://discourse.mitmproxy.org/u/aniketpanjwani)\
**Post date:** [January 29, 2018, 4:22pm UTC](https://discourse.mitmproxy.org/t/adding-arguments-to-scripts/818/3 "2018-01-29T16:22:37Z")

</div>

Gotcha - I now realize that I was having two separate problems.

1. I had the 3.0 mitmproxy binaries installed on my system, but I had 2.0.2 installed in a virtual environment which I’m using to develop something around mitmproxy. This is because I used pip to install mitmproxy in the virtual environment without directing it to the Git repository.
2. There’s possibly a small mistake in [the documentation](https://github.com/mitmproxy/mitmproxy/tree/master/examples/simple). [readme.md](http://readme.md) should include custom\_option.py, and it should not include script\_argument.py, which is not in the folder. I missed custom\_option.py since it wasn’t in the table.

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![mhils](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/mhils/32/7_2.png) [@mhils](https://discourse.mitmproxy.org/u/mhils)\
**Post date:** [January 29, 2018, 5:38pm UTC](https://discourse.mitmproxy.org/t/adding-arguments-to-scripts/818/4 "2018-01-29T17:38:51Z")

</div>

Good point - would you mind sending a PR that fixes that? 🙂

---

<div class="post-metadata">

**Author:** ![aniketpanjwani](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/aniketpanjwani/32/266_2.png) [@aniketpanjwani](https://discourse.mitmproxy.org/u/aniketpanjwani)\
**Post date:** [January 29, 2018, 6:11pm UTC](https://discourse.mitmproxy.org/t/adding-arguments-to-scripts/818/5 "2018-01-29T18:11:21Z")

</div>

Just made one. For some reason discourse won’t let me put the link here, but it’s pull request 2820. Also, not sure why my above posts just got flagged as spam.
