# Implement C-like command line arguments in Julia

**URL:** https://discourse.julialang.org/t/implement-c-like-command-line-arguments-in-julia/67816
**Category:** New to Julia
**Tags:** c
**Created:** [September 7, 2021, 1:21pm UTC](https://discourse.julialang.org/t/implement-c-like-command-line-arguments-in-julia/67816 "2021-09-07T13:21:31Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![vinicius\_de\_lima](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vinicius_de_lima/32/28717_2.png) [@vinicius\_de\_lima](https://discourse.julialang.org/u/vinicius_de_lima)
#### Post date: [September 7, 2021, 1:21pm UTC](https://discourse.julialang.org/t/implement-c-like-command-line-arguments-in-julia/67816/1 "2021-09-07T13:21:31Z")

</div>

There is a way to reproduce C command line arguments behavior in Julia?

```julia
int main(int argc, char **argv) { /* ... */ }

```

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [September 7, 2021, 1:24pm UTC](https://discourse.julialang.org/t/implement-c-like-command-line-arguments-in-julia/67816/2 "2021-09-07T13:24:24Z")

</div>

I used [DocOpt.jl](https://github.com/docopt/DocOpt.jl) in the past and liked it. But I remember a newer approach as well. If I remember the link I will share here.

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [September 7, 2021, 1:25pm UTC](https://discourse.julialang.org/t/implement-c-like-command-line-arguments-in-julia/67816/3 "2021-09-07T13:25:48Z")

</div>

Here it is: [https://github.com/comonicon/Comonicon.jl](https://github.com/comonicon/Comonicon.jl)

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [September 7, 2021, 2:32pm UTC](https://discourse.julialang.org/t/implement-c-like-command-line-arguments-in-julia/67816/4 "2021-09-07T14:32:44Z")

</div>

> [@vinicius\_de\_lima](#):
>
> There is a way to reproduce C command line arguments behavior in Julia?

At the lowest level, the equivalent of the C `argc`/`argv` variables is the [`ARGS` global constant](https://docs.julialang.org/en/v1/base/constants/#Base.ARGS), which is a list of strings giving the command-line arguments passed by the user.

On top of that, there are various higher-level packages to help you parse command-line arguments. For example, an analogue of the C `getopt` API in Julia is provided by the [ArgParse package](https://github.com/carlobaldassi/ArgParse.jl), and then there are also the abovementioned DocOpt and Comonicon packages.

---

<div class="post-metadata">

### Author: ![dmitry-kabanov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmitry-kabanov/32/52639_2.png) [@dmitry-kabanov](https://discourse.julialang.org/u/dmitry-kabanov)
#### Post date: [November 17, 2025, 11:11am UTC](https://discourse.julialang.org/t/implement-c-like-command-line-arguments-in-julia/67816/5 "2025-11-17T11:11:56Z")

</div>

I was just investigating the same question, and a bit surprised that one needs to install a third-party package for that. Shouldn’t it be a part of the standard library? Besides, looking at the GitHub repos (in November 2025):

- DocOpt.jl - looks abandoned: `src` is updated 4 years ago, `tests` 7 years ago
- `Comonicon.jl` the repo is updated 8 months ago, OK, however the last release is in May 2024 and the CI badge says “failing”
- `ArgParse.jl` looks the most maintained right now, although the last release is also May 2024.

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)
#### Post date: [November 17, 2025, 11:32am UTC](https://discourse.julialang.org/t/implement-c-like-command-line-arguments-in-julia/67816/6 "2025-11-17T11:32:59Z")

</div>

The standard is that you get a vector of strings, beyond that, you can really do anything you want with those strings so I’m not sure how parsing that could be a good candidate for Base functionality. There’s just too many approaches to it.

---

<div class="post-metadata">

### Author: ![dmitry-kabanov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmitry-kabanov/32/52639_2.png) [@dmitry-kabanov](https://discourse.julialang.org/u/dmitry-kabanov)
#### Post date: [November 17, 2025, 11:34am UTC](https://discourse.julialang.org/t/implement-c-like-command-line-arguments-in-julia/67816/7 "2025-11-17T11:34:32Z")

</div>

@jules I think I am too spoiled by Python 🙂

UPDATED: On a second thought, there are components in the standard library like LibGit2, Tar, and Markdown, which look to me much more tangential to day-to-day programming tasks than parsing command-line arguments.

---

<div class="post-metadata">

### Author: ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)
#### Post date: [November 17, 2025, 12:07pm UTC](https://discourse.julialang.org/t/implement-c-like-command-line-arguments-in-julia/67816/8 "2025-11-17T12:07:00Z")

</div>

For those specific examples, LibGit2 and Tar are critical components for the (built in) package manager and Markdown is used to present docstrings within the Julia REPL.

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)
#### Post date: [November 17, 2025, 1:07pm UTC](https://discourse.julialang.org/t/implement-c-like-command-line-arguments-in-julia/67816/9 "2025-11-17T13:07:15Z")

</div>

Sure it can be nice if _something_ is available by default, but even the python docs for argparse, which I assume you mean, say right at the top:

> While [`argparse`](https://docs.python.org/3/library/argparse.html#module-argparse) is the default recommended standard library module for implementing basic command line applications, authors with more exacting requirements for exactly how their command line applications behave may find it doesn’t provide the necessary level of control. Refer to [Choosing an argument parsing library](https://docs.python.org/3/library/optparse.html#choosing-an-argument-parser) for alternatives to consider when `argparse` doesn’t support behaviors that the application requires (such as entirely disabling support for interspersed options and positional arguments, or accepting option parameter values that start with `-` even when they correspond to another defined option).

In Julia, I think we generally err on the side of not putting stuff into Base in such cases although arguments can be made for either position.
