Args (gb.args)

该类重载于 Argsgb中.

该类是静态类。

该类行为像一个只读静态数组。

FOR EACH关键字静态可枚举该类。

静态属性
Abort  

Inherited static properties
All  
Count  
Max  

静态方法
Begin  
End  
Get  
GetFloat  
GetInteger  
Has  
HelpText   Get the default help message.
Must be used after Args.Begin() Returns the message text and will Print to stdout if boolean arg PrintText is True.

Inherited static methods
Copy  

该类分析当前进程的参数。

允许:
  • 从程序参数中提取选项。

  • 自动处理 --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