Commons Cli 简介

Apache Commons CLI 库提供了一个用于解析传递给程序的命令行选项的 API。它还可以打印帮助消息,详细说明命令行工具可用的选项。

Apache Commons CLI 支持不同类型的选项:

  • 类似POSIX选项,例如:tar -zxvf foo.tar.gz

  • 类似GNU的长选项,例如:du --human-readable --max-depth=1

  • 类似Java属性,例如:java -Djava.awt.headless=true -Djava.net.useSystemProxies=true Foo

  • 短选项附加值,例如:gcc -O2 foo.c

  • 长选项单个连接符,例如:ant -projecthelp

下面是一个由 Apache Commons CLI 显示的一个典型的帮助消息,如下:

usage: ls
 -A,--almost-alldo not list implied . and ..
 -a,--all                 do not hide entries starting with .
 -B,--ignore-backups      do not list implied entried ending with ~
 -b,--escape           print octal escapes for nongraphic characters
    --block-size <SIZE>   use SIZE-byte blocks
 -c                  with -lt: sort by, and show, ctime (time of last
                     modification of file status information) with
                      -l:show ctime and sort by name otherwise: sort
                      by ctime
 -C                list entries by columns
说说我的看法
全部评论(
没有评论
关于
本网站属于个人的非赢利性网站,转载的文章遵循原作者的版权声明,如果原文没有版权声明,请来信告知:hxstrive@outlook.com
公众号