# Can i optionally pass argument to gatling commandline

**URL:** <https://community.gatling.io/t/can-i-optionally-pass-argument-to-gatling-commandline/7201>\
**Category:** Gatling (Open-Source)\
**Created:** [October 8, 2022, 2:27pm UTC](https://community.gatling.io/t/can-i-optionally-pass-argument-to-gatling-commandline/7201 "2022-10-08T14:27:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shobithbv.2](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@shobithbv.2](https://community.gatling.io/u/shobithbv.2)\
**Post date:** [October 8, 2022, 2:27pm UTC](https://community.gatling.io/t/can-i-optionally-pass-argument-to-gatling-commandline/7201/1 "2022-10-08T14:27:36Z")

</div>

there are some scenario i need to run against specific number of users irrespective of total duration of test run. and some run against total duration irrespective of users.  
hence, setting “-Dusers -Dduration” while executing a mvn command should run tests against users and if i dont pass “-Dusers” in mvn command, test should run agsinst the duration. Is there any option to do so?

---

<div class="post-metadata">

**Author:** ![GeMi](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/gemi/32/939_2.png) [@GeMi](https://community.gatling.io/u/GeMi)\
**Post date:** [October 9, 2022, 7:45am UTC](https://community.gatling.io/t/can-i-optionally-pass-argument-to-gatling-commandline/7201/2 "2022-10-09T07:45:11Z")

</div>

Please check Example:  
[Case0006CommandLineParametersSimulation](https://github.com/gemiusz/gatling-examples-maven-java/blob/master/src/test/java/pl/gemiusz/Case0006CommandLineParametersSimulation.java)  
or thread:  
[Cannot Grab Command Line Arguments](https://community.gatling.io/t/cannot-grab-command-line-arguments/7025)

---

<div class="post-metadata">

**Author:** ![shobithbv.2](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@shobithbv.2](https://community.gatling.io/u/shobithbv.2)\
**Post date:** [October 11, 2022, 8:18am UTC](https://community.gatling.io/t/can-i-optionally-pass-argument-to-gatling-commandline/7201/3 "2022-10-11T08:18:10Z")

</div>

Thanks for your suggestion. I think these are commands to be sent mandatorily while execution. But, my question is to run these optionally.  
For ex: if i mention “-DrunSmokeTest=yes”, it should run the smoke test. Else (if i dont give the argument “-DrunSmokeTest”, it has to run the entire test

---

<div class="post-metadata">

**Author:** ![GeMi](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/gemi/32/939_2.png) [@GeMi](https://community.gatling.io/u/GeMi)\
**Post date:** [October 11, 2022, 12:16pm UTC](https://community.gatling.io/t/can-i-optionally-pass-argument-to-gatling-commandline/7201/4 "2022-10-11T12:16:19Z")

</div>

I don’t understand what you want to achieve.  
Can you elaborate a little more your needs.

---

<div class="post-metadata">

**Author:** ![sbrevet](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/sbrevet/32/830_2.png) [@sbrevet](https://community.gatling.io/u/sbrevet)\
**Post date:** [October 11, 2022, 1:12pm UTC](https://community.gatling.io/t/can-i-optionally-pass-argument-to-gatling-commandline/7201/5 "2022-10-11T13:12:37Z")

</div>

Perhaps this thread about configuring a list of scenarios may help you:

> [@Dynamically adding scenarios based on loop](https://community.gatling.io/t/dynamically-adding-scenarios-based-on-loop/7192):
>
> It is possible to loop the Scenario injection like below:- setUp( (1 to 3).flatMap(i =\> Seq( matchScenario.inject( rampConcurrentUsers(1) to t\_concurrency during t\_rampUp, constantConcurrentUsers(t\_concurrency) during t\_holdFor, rampConcurrentUsers(t\_concurrency) to 1 during t\_rampUp )))).protocols(httpConf) ).maxDuration(t\_holdFor + 2\*t\_rampUp) //stop the test after maxDuration time is completed }
