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

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

问题描述

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

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

我已经声明了 ab 选项,并且我能够使用 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天全站免登陆