From 42ec7286b2d36a9ba22925f816a17cb1cc2aa5ce Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 30 Oct 2021 11:32:16 +0800 Subject: + Penlight --- .../Libraries/Penlight/docs/libraries/pl.lapp.html | 382 +++++++++++++++++++++ 1 file changed, 382 insertions(+) create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.lapp.html (limited to 'Data/Libraries/Penlight/docs/libraries/pl.lapp.html') diff --git a/Data/Libraries/Penlight/docs/libraries/pl.lapp.html b/Data/Libraries/Penlight/docs/libraries/pl.lapp.html new file mode 100644 index 0000000..24a1079 --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.lapp.html @@ -0,0 +1,382 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.lapp

+

Simple command-line parsing using human-readable specification.

+

Supports GNU-style parameters.

+ + +
+lapp = require 'pl.lapp'
+local args = lapp [[
+Does some calculations
+  -o,--offset (default 0.0)  Offset to add to scaled number
+  -s,--scale  (number)  Scaling factor
+  <number> (number) Number to be scaled
+]]
+
+print(args.offset + args.scale * args.number)
+
+ +

Lines beginning with '-' are flags; there may be a short and a long name; + lines beginning with '<var>' are arguments. Anything in parens after + the flag/argument is either a default, a type name or a range constraint.

+ +

See the Guide

+ +

Dependencies: pl.sip

+ + +

Functions

+ + + + + + + + + + + + + + + + + + + + + + + + + +
quit (msg, no_usage)quit this script immediately.
error (msg, no_usage)print an error to stderr and quit.
open (file[, opt])open a file.
assert (condn, msg)quit if the condition is false.
add_type (name, converter[, constraint])add a new type to Lapp.
process_options_string (str, args)process a Lapp options string.
+

Fields

+ + + + + +
show_usage_errorcontrols whether to dump usage on error.
+ +
+
+ + +

Functions

+ +
+
+ + quit (msg, no_usage) +
+
+ quit this script immediately. + + +

Parameters:

+
    +
  • msg + string + optional message +
  • +
  • no_usage + bool + suppress 'usage' display +
  • +
+ + + + + +
+
+ + error (msg, no_usage) +
+
+ print an error to stderr and quit. + + +

Parameters:

+
    +
  • msg + string + a message +
  • +
  • no_usage + bool + suppress 'usage' display +
  • +
+ + + + + +
+
+ + open (file[, opt]) +
+
+ open a file. + This will quit on error, and keep a list of file objects for later cleanup. + + +

Parameters:

+
    +
  • file + string + filename +
  • +
  • opt + string + same as second parameter of io.open + (optional) +
  • +
+ + + + + +
+
+ + assert (condn, msg) +
+
+ quit if the condition is false. + + +

Parameters:

+
    +
  • condn + bool + a condition +
  • +
  • msg + string + message text +
  • +
+ + + + + +
+
+ + add_type (name, converter[, constraint]) +
+
+ add a new type to Lapp. These appear in parens after the value like + a range constraint, e.g. ' (integer) Process PID' + + +

Parameters:

+
    +
  • name + string + name of type +
  • +
  • converter + either a function to convert values, or a Lua type name. +
  • +
  • constraint + func + optional function to verify values, should use lapp.error + if failed. + (optional) +
  • +
+ + + + + +
+
+ + process_options_string (str, args) +
+
+ process a Lapp options string. + Usually called as lapp(). + + +

Parameters:

+
    +
  • str + string + the options text +
  • +
  • args + {string} + a table of arguments (default is _G.arg) +
  • +
+ +

Returns:

+
    + + a table with parameter-value pairs +
+ + + + +
+
+

Fields

+ +
+
+ + show_usage_error +
+
+ controls whether to dump usage on error. + Defaults to true + + + + + + + +
+
+ + +
+
+
+generated by LDoc 1.4.6 +
+
+ + -- cgit v1.1-26-g67d0