Skip to content
This repository was archived by the owner on Jul 7, 2024. It is now read-only.

Options

SquidDev edited this page Jan 5, 2015 · 7 revisions

Arguments are parsed when the program launches in the following patterns:

  • --key=value Sets the options key to be value
  • --key Sets the option key to be true.
  • -vt Sets the options v and t to be true.

Handling options

Options do not need to be explicitly added, but it is recommended as some features (aliases, using -vt style arguments) will not be available.

All functions can be called in two ways:

Options:Description("verbose", "Print verbose output")
-- or
Options:Option "verbose"
    :Description "Print verbose output"

The first is suggested for single setters, the second for multiple settings.

Properties

  • Default: :Default(value or true) Set the default value
  • Alias: :Alias(alias) Add an alias the command
  • Description: :Description(description) Set the description (for help contents)
  • TakesValue: :TakesValue(takesValue) If the argument takes a value (for help contents)

Callbacks

Whenever a value is changed the OnChanged event is called. You can listen to it with:

Options:OnChanged(function(parser)
 print("Something changed")
end)

This is used to update verbose printing, amongst other things.

Utilities

Help messages

Call Options:Help(indent = '') to print out the list of options currently available.

Clone this wiki locally