# moonbit现在是否支持命令行应用开发

**URL:** <https://taolun.moonbitlang.com/t/topic/1093>\
**Category:** 代码帮助\
**Tags:** moonbit-lang\
**Created:** [2024 年12 月 19 日 06:26 UTC](https://taolun.moonbitlang.com/t/topic/1093 "2024-12-19T06:26:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

作者： ![bitwool](https://taolun.moonbitlang.com/user_avatar/taolun.moonbitlang.com/bitwool/32/621_2.png) [@bitwool](https://taolun.moonbitlang.com/u/bitwool)\
发布日期： [2024 年12 月 19 日 06:26 UTC](https://taolun.moonbitlang.com/t/topic/1093/1 "2024-12-19T06:26:17Z")

</div>

如果支持的话，应该如何解析命令行参数

---

<div class="post-metadata">

作者： ![ChenYubin](https://taolun.moonbitlang.com/letter_avatar_proxy/v4/letter/c/ee59a6/32.png) [@ChenYubin](https://taolun.moonbitlang.com/u/ChenYubin)\
发布日期： [2024 年12 月 19 日 09:55 UTC](https://taolun.moonbitlang.com/t/topic/1093/2 "2024-12-19T09:55:20Z")

</div>

1. 获取命令行参数

可以通过实验库[`x/sys`](https://mooncakes.io/docs/#/moonbitlang/x/sys/members)，配合moonbit工具链自带的默认runtime，获取命令行输入。

1. 解析命令行参数

`x/sys` 给出的只是一系列字符串，你可以使用[`yoorkin/ArgParser`](https://mooncakes.io/docs/#/Yoorkin/ArgParser/) 解析字符串，从而声明式地配置命令行选项

---

<div class="post-metadata">

作者： ![bitwool](https://taolun.moonbitlang.com/user_avatar/taolun.moonbitlang.com/bitwool/32/621_2.png) [@bitwool](https://taolun.moonbitlang.com/u/bitwool)\
发布日期： [2024 年12 月 23 日 01:04 UTC](https://taolun.moonbitlang.com/t/topic/1093/3 "2024-12-23T01:04:21Z")

</div>

感谢  
附示例代码

```auto
 moon add moonbitlang/x 

```

moon.pkg.json

```json
{
  "is-main": true,
  "import": ["moonbitlang/x/sys"]
}

```

main.mbt

```auto
fn main {
  let args = @sys.get_cli_args()
  for arg in args {
    println(arg)
  }
}

```
