Skip to content

Commit b8409b7

Browse files
committed
Improve help messages for global-related options
1 parent 00c1f8e commit b8409b7

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

docsrc/cli.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ Option Meaning
8686
* ``none`` - no standard globals.
8787

8888
See :ref:`stds`
89-
``--globals [<global>] ...`` Add custom globals on top of standard ones.
90-
``--read-globals [<global>] ...`` Add read-only globals.
91-
``--new-globals [<global>] ...`` Set custom globals. Removes custom globals added previously.
92-
``--new-read-globals [<global>] ...`` Set read-only globals. Removes read-only globals added previously.
93-
``--not-globals [<global>] ...`` Remove custom and standard globals.
89+
``--globals [<name>] ...`` Add custom global variables or fields on top of standard ones. See :ref:`fields`
90+
``--read-globals [<name>] ...`` Add read-only global variables or fields.
91+
``--new-globals [<name>] ...`` Set custom global variables or fields. Removes custom globals added previously.
92+
``--new-read-globals [<name>] ...`` Set read-only global variables or fields. Removes read-only globals added previously.
93+
``--not-globals [<name>] ...`` Remove custom and standard global variables or fields.
9494
``-c | --compat`` Equivalent to ``--std max``.
9595
``-d | --allow-defined`` Allow defining globals implicitly by setting them.
9696

@@ -151,6 +151,8 @@ Pattern Matching warnings
151151

152152
Unless already anchored, patterns matching variable names are anchored at both sides and patterns matching warning codes are anchored at their beginnings. This allows one to filter warnings by category (e.g. ``--only 1`` focuses ``luacheck`` on global-related warnings).
153153

154+
.. _fields:
155+
154156
Defining extra globals and fields
155157
---------------------------------
156158

src/luacheck/main.lua

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,36 +81,37 @@ together with used ones.]]):target("unused_secondaries"):action("store_false")
8181
none - no standard globals.
8282
8383
Sets can be combined using "+".]]):format(default_std_name))
84-
parser:option("--globals", "Add custom globals on top of standard ones.")
84+
parser:option("--globals", [[Add custom global variables (e.g. foo) or
85+
fields (e.g. foo.bar) on top of standard ones.]])
8586
:args "*"
8687
:count "*"
87-
:argname "<global>"
88+
:argname "<name>"
8889
:action "concat"
8990
:init(nil)
90-
parser:option("--read-globals", "Add read-only globals.")
91+
parser:option("--read-globals", "Add read-only global variables or fields.")
9192
:args "*"
9293
:count "*"
93-
:argname "<global>"
94+
:argname "<name>"
9495
:action "concat"
9596
:init(nil)
96-
parser:option("--new-globals", [[Set custom globals. Removes custom globals added
97-
previously.]])
97+
parser:option("--new-globals", [[Set custom global variables or fields. Removes
98+
custom globals added previously.]])
9899
:args "*"
99100
:count "*"
100-
:argname "<global>"
101+
:argname "<name>"
101102
:action "concat"
102103
:init(nil)
103-
parser:option("--new-read-globals", [[Set read-only globals. Removes read-only globals added
104-
previously.]])
104+
parser:option("--new-read-globals", [[Set read-only global variables or fields. Removes
105+
read-only globals added previously.]])
105106
:args "*"
106107
:count "*"
107-
:argname "<global>"
108+
:argname "<name>"
108109
:action "concat"
109110
:init(nil)
110-
parser:option("--not-globals", "Remove custom and standard globals.")
111+
parser:option("--not-globals", "Remove custom and standard global variables or fields.")
111112
:args "*"
112113
:count "*"
113-
:argname "<global>"
114+
:argname "<name>"
114115
:action "concat"
115116
:init(nil)
116117
parser:flag("-c --compat", "Equivalent to --std max.")

0 commit comments

Comments
 (0)