使用Apache Commons CLI库时如何获取参数 [英] How to fetch parameters when using the Apache Commons CLI library

查看:187
本文介绍了使用Apache Commons CLI库时如何获取参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Apache Commons CLI来处理Java中的命令行参数。

I'm using the Apache Commons CLI to handle command line arguments in Java.

我已声明 a b 选项,我可以使用 CommandLine.getOptionValue()来访问该值。

I've declared the a and b options and I'm able to access the value using CommandLine.getOptionValue().

Usage: myapp [OPTION] [DIRECTORY]

Options:
-a        Option A
-b        Option B

如何声明和访问DIRECTORY变量?

How do I declare and access the DIRECTORY variable?

推荐答案

使用以下方法:

CommandLine.getArgList()

返回处理选项后剩余的内容。

which returns whatever's left after options have been processed.

这篇关于使用Apache Commons CLI库时如何获取参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆