Skip to content

Commit

Permalink
Add quiet option
Browse files Browse the repository at this point in the history
* Update stuck-worship.rst
* Update stuck-worship.lua
* Update registry.lua
  • Loading branch information
Bumber64 authored Sep 30, 2024
1 parent f2aaeb8 commit cbffc93
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
25 changes: 22 additions & 3 deletions docs/fix/stuck-worship.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,26 @@ another task.
Usage
-----

::

fix/stuck-worship [<options>]

Reshuffle prayer needs of units in the fort.

Examples
--------

``fix/stuck-worship``
Rebalance prayer needs of units in the fort.
``fix/stuck-worship -v``, ``fix/stuck-worship --verbose``
Rebalance prayer needs of units in the fort. Print names of affected units.
Rebalance prayer needs and print the total number of affected units.
``fix/stuck-worship -v``
Same as above, but also print the names of all affected units.

Options
-------

``-v``, ``--verbose``
Print the names of all affected units.
``-q``, ``--quiet``
Don't print the number of affected units if it's zero. Intended for
automatic use.

5 changes: 3 additions & 2 deletions fix/stuck-worship.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
local argparse = require('argparse')

local verbose = false
local verbose, quiet = false, false
argparse.processArgsGetopt({...}, {
{'v', 'verbose', handler=function() verbose = true end},
{'q', 'quiet', handler=function() quiet = true end},
})

local function for_pray_need(needs, fn)
Expand Down Expand Up @@ -106,6 +107,6 @@ for _,unit in ipairs(dfhack.units.getCitizens(false, true)) do
::next_unit::
end

if verbose or count > 0 then
if not quiet or count > 0 then
print(('Rebalanced prayer needs for %d units.'):format(count))
end
2 changes: 1 addition & 1 deletion internal/control-panel/registry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ COMMANDS_BY_IDX = {
desc='Fix activity references on stuck instruments to make them usable again.',
params={'--time', '1', '--timeUnits', 'days', '--command', '[', 'fix/stuck-instruments', ']'}},
{command='fix/stuck-worship', group='bugfix', mode='repeat', default=true,
params={'--time', '1', '--timeUnits', 'days', '--command', '[', 'fix/stuck-worship', ']'}},
params={'--time', '1', '--timeUnits', 'days', '--command', '[', 'fix/stuck-worship', '-q', ']'}},
{command='fix/noexert-exhaustion', group='bugfix', mode='repeat', default=true,
params={'--time', '439', '--timeUnits', 'ticks', '--command', '[', 'fix/noexert-exhaustion', ']'}},
{command='flask-contents', help_command='tweak', group='bugfix', mode='tweak', default=true,
Expand Down

0 comments on commit cbffc93

Please sign in to comment.