Args (gb.args)
静态属性
Inherited static properties
静态方法
Inherited static methods
该类分析当前进程的参数。
允许:
-
从程序参数中提取选项。
-
自动处理
--version
和 --help
选项。
-
返回非选项作为参数。
使用
Begin 方法开始选项分析,使用
End 方法终止选项分析。
将自动打印帮助、用法和版本信息到标准输出。
如果发生错误,程序将退出,退出代码为
1
。
自从 3.16.4
设置
Args.Abort = False
以便覆盖退出并自己处理错误。
自从 3.16
您可以使用 Args.Has()来人工检查 -V --version 或 -h --help ,然后默认输出将被抑制,您的应用程序也不会退出。
这对于显示您自己的自定义帮助或版本消息非常有用。
Args.HelpText() can be used to get or print the original help text if you are handling the -h manually but it
MUST ONLY be called
AFTER calling Args.End() or the help texts will not yet have been constructed.
Public Sub Main()
Dim bHelp As Boolean
Args.Begin(Application.Name & " <options>")
bHelp = Args.Has("h", "help", "Display a customised help message")
Args.End()
If bHelp Then
Args.HelpText(True) ' Print standard help text to terminal
Print "Additional Help message can be written here"
' Now exit the program as overriding the -h argument will stop it automatically quitting.
Quit
Endif
End