-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add --oldest and --clear features to prioritize
#851
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,6 +200,33 @@ local function boost(job_matchers, opts) | |
end | ||
end | ||
|
||
local function boost_oldest(job_matchers, opts) | ||
local quiet = opts.quiet | ||
local count = opts.oldest_count | ||
local job = df.global.world.jobs.list | ||
while ( job.next ) do | ||
job = job.next | ||
if (job.item and not job.item.flags.do_now and job.item.order_id == -1) then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see this excludes manager orders. should it also exclude repeat jobs? what about jobs that already have a worker attached and are in progress? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it probably should preclude repeat jobs, i don't use those in my forts except very rarely so it did not come up for me the others are also good ideas |
||
job.item.flags.do_now = true | ||
count = count - 1 | ||
if (count <= 0) then | ||
return true | ||
end | ||
end | ||
end | ||
end | ||
|
||
local function clear_all(job_matchers, opts) | ||
local quiet = opts.quiet | ||
local job = df.global.world.jobs.list | ||
while ( job.next ) do | ||
job = job.next | ||
if (job.item and job.item.flags.do_now) then | ||
job.item.flags.do_now = false | ||
end | ||
end | ||
end | ||
|
||
local function print_add_message(job_type, annotation) | ||
annotation = annotation or '' | ||
print(('Automatically prioritizing future jobs of type: %s%s') | ||
|
@@ -479,6 +506,13 @@ end | |
local function parse_commandline(args) | ||
local opts, action, unit_labors, reaction_names = {}, status, nil, nil | ||
local positionals = argparse.processArgsGetopt(args, { | ||
{'o', 'oldest', hasArg=true, handler=function(arg) | ||
action = boost_oldest | ||
opts.oldest_count = arg | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest using |
||
end}, | ||
{'z', 'clear', handler=function(arg) | ||
action = clear_all | ||
end}, | ||
{'a', 'add', handler=function() action = boost_and_watch end}, | ||
{'d', 'delete', handler=function() action = remove_watch end}, | ||
{'h', 'help', handler=function() opts.help = true end}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider
job
here islink.item
, and it takes care of the initial nil for you so you don't have to check for nil