# \[ANN\] Runner.jl: Run with commandline args from REPL

**URL:** https://discourse.julialang.org/t/ann-runner-jl-run-with-commandline-args-from-repl/44796
**Category:** Package Announcements
**Tags:** repl
**Created:** [August 12, 2020, 10:11am UTC](https://discourse.julialang.org/t/ann-runner-jl-run-with-commandline-args-from-repl/44796 "2020-08-12T10:11:27Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![v-i-s-h](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/v-i-s-h/32/46152_2.png) [@v-i-s-h](https://discourse.julialang.org/u/v-i-s-h)
#### Post date: [August 12, 2020, 10:11am UTC](https://discourse.julialang.org/t/ann-runner-jl-run-with-commandline-args-from-repl/44796/1 "2020-08-12T10:11:27Z")

</div>

Hi,  
I am pleased to announce a small package which will help in running codes with command line args from REPL. Recently, I have been working with Plots, Flux etc, where the package load time is quite high. While loading in REPL and running with `include()` is the first solution to avoid wait times during loading, I also wanted the scripts to be able to take in command line arguments. Hence born `Runner.jl`. Please find the details below:

Repo: [GitHub - v-i-s-h/Runner.jl: Provides `@runit` macro for running scripts with commandline arguments from REPL](https://github.com/v-i-s-h/Runner.jl)

Installation: `]add Runner`

I welcome feedback from the community.

# Runner.jl

**TL;DR** Provides `@runit` macro for running scripts with commandline arguments from REPL.

Instead of

```julia-auto
$julia script.jl arg1 arg2 arg3

```

use, from REPL

```julia-auto
julia> @runit "script.jl arg1 arg2 arg3"

```

**Advantage** : Avoid the delay in package load times during development. Load it once using REPL and continue using it with commandline arguments.

## Why?

This packages tries to solve the problem of running scripts with commandline arguments from REPL. Often we write scripts that can be called from commandline with arguments like

```julia-auto
$julia script.jl arg1 arg2 arg3

```

However, during development, this may become cumbersome. If we use some packages which has long load times, running the script as above will create long delays before actually executing the code. A faster approach during development is to start a REPL and use

```julia-auto
julia> include('script.jl')

```

But, in this case, we will not be able to provide command line arguments. Work around is to define a function which takes in arguments and manually calling it. Not neat!

This package exists to overcome this difficulty. It provide a macro `@runit` which will let you run script from REPL with commandline arguments.

## How?

### Simple use case

If you have a script like

```julia-auto
# hello.jl
# Simple script for demo. Accesses ARGS
println("Hello $(ARGS[1])!")

```

From commadline, we can run this as

```julia-auto
$julia hello.jl Julia

```

To run this from REPL, use

```julia-auto
julia> @runit hello.jl Julia

```

### Use with `ArgParse`

```julia-auto
# Script hello2.jl
using ArgParse

parser = ArgParseSettings()
@add_arg_table! parser begin
    "name"
	    help = "Name to greet"
  	    arg_type = String
    "--greet"
        help = "Greeting sting"
        arg_type = String
        default = "Hello"
end

parsed_args = parse_args(parser)

println(parsed_args["greet"], " ", parsed_args["name"], "!")

```

From commandline

```julia-auto
$julia hello2.jl Julia
Hello Julia!

$julia hello2.jl Julia --greet Namaste
Namaste Julia!

```

From REPL

```julia-auto
julia> @runit "hello2.jl Julia"
Hello Julia!

julia> @runit "hello2.jl Julia --greet Namaste"
Namaste Julia!

```

---

<div class="post-metadata">

### Author: ![anon37204545](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@anon37204545](https://discourse.julialang.org/u/anon37204545)
#### Post date: [August 12, 2020, 10:27am UTC](https://discourse.julialang.org/t/ann-runner-jl-run-with-commandline-args-from-repl/44796/2 "2020-08-12T10:27:16Z")

</div>

Make a w-i-s-h and v-i-s-h will make it come true! Nice package. 😉
