Skip to content

Commit 27d3e79

Browse files
claudemrhoribu
authored andcommitted
feat(bigshot.lic): v5.16.0 add ;bigshot help and unknown-option fallback
There was no ;bigshot help, and no else on the CLI dispatch chain - ;bigshot help and any mistyped option both silently did nothing. The only help text anywhere in the script was ;bigshot debug help. Adds Bigshot.help, mirroring debug_help's existing pattern: a Terminal::Table when the gem is loaded, plain respond lines otherwise, so it degrades on front ends without table support. Documents the full CLI surface - hunting modes, group (head/tail/link), setup/profile/ display/list/reset, and debug/test - plus a pointer to the gswiki for the command-check modifier reference, which is out of scope for this script's own --help output. Wired in two places: - a new branch ahead of the mode branch, anchored /\Ahelp\z/i so it can't collide with any other keyword - a new else on the dispatch chain, so an unknown option now names itself and prints help instead of doing nothing
1 parent ae9dfb7 commit 27d3e79

1 file changed

Lines changed: 103 additions & 1 deletion

File tree

scripts/bigshot.lic

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2578,25 +2578,122 @@ class Bigshot
25782578
end
25792579
end
25802580

2581+
# Discards every queued event.
2582+
#
2583+
# @return [void]
25812584
def clear_events()
25822585
debug_msg(@DEBUG_SYSTEM, "clear_events")
25832586
@event_stack.clear
25842587
end
25852588

2589+
# Pops the next queued event.
2590+
#
2591+
# @return [Bigshot::Event, nil] the oldest event, or nil when the queue is empty
25862592
def grab_event()
25872593
debug_msg(@DEBUG_SYSTEM, "grab_event")
25882594
@event_stack.shift()
25892595
end
25902596

2597+
# Liveness probe used by the leader to detect disconnected followers.
2598+
#
2599+
# Always returns true; the value is irrelevant, since a dead follower raises
2600+
# +DRb::DRbConnError+ on the call itself and is dropped by
2601+
# {Bigshot::Group#member_online}.
2602+
#
2603+
# @return [true]
25912604
def ping
25922605
# checks if follower got disconnected
25932606
return true
25942607
end
25952608

2609+
# Removes every queued event of a given type.
2610+
#
2611+
# @param item [Symbol] event type to drop
2612+
# @return [void]
25962613
def remove_event(item)
25972614
@event_stack.reject! { |event| event.type == item }
25982615
end
25992616

2617+
# Prints the top-level command reference for the script.
2618+
#
2619+
# Mirrors {debug_help}: renders a Terminal::Table when the gem is loaded and
2620+
# falls back to plain +respond+ lines otherwise, so the output is usable on
2621+
# front ends without table support.
2622+
#
2623+
# @return [void]
2624+
# @see debug_help
2625+
def self.help
2626+
name = Script.current.name
2627+
rows = [
2628+
["#{$lich_char}#{name}", "Hunt solo in the current room"],
2629+
["#{$lich_char}#{name} bounty", "Hunt to complete the current bounty"],
2630+
["#{$lich_char}#{name} quick", "Hunt without wandering (current room only)"],
2631+
["#{$lich_char}#{name} once", "Hunt a single loop, then exit"],
2632+
["#{$lich_char}#{name} <creature>", "Rangers: TRACK toward the named creature"],
2633+
[:separator, :separator],
2634+
["#{$lich_char}#{name} head <count>", "Lead a group; waits for <count> followers"],
2635+
["#{$lich_char}#{name} tail", "Follow a group leader (auto-discovers)"],
2636+
["#{$lich_char}#{name} link <uri>", "Follow a leader at an explicit DRb URI"],
2637+
[:separator, :separator],
2638+
["#{$lich_char}#{name} setup", "Open the settings window"],
2639+
["#{$lich_char}#{name} profile load <name>", "Load a saved profile"],
2640+
["#{$lich_char}#{name} profile save <name>", "Save the current settings as a profile"],
2641+
["#{$lich_char}#{name} display", "Show version and active settings"],
2642+
["#{$lich_char}#{name} list", "Show every initialized value"],
2643+
["#{$lich_char}#{name} reset", "Clear targetable/untargetable settings"],
2644+
[:separator, :separator],
2645+
["#{$lich_char}#{name} debug help", "Debug logging options"],
2646+
["#{$lich_char}#{name} test <method> [args]", "Invoke a single method (development)"],
2647+
["#{$lich_char}#{name} help", "This help"]
2648+
]
2649+
2650+
if defined?(Terminal)
2651+
table_rows = []
2652+
table_rows << [{ :value => "Modes can be combined, e.g. #{$lich_char}#{name} bounty quick", :colspan => 2, :alignment => :left }]
2653+
table_rows << :separator
2654+
rows.each do |left, right|
2655+
if left == :separator
2656+
table_rows << :separator
2657+
else
2658+
table_rows << [{ :value => left, :alignment => :left }, { :value => right, :alignment => :right }]
2659+
end
2660+
end
2661+
table_rows << :separator
2662+
table_rows << [{ :value => "Full documentation: https://gswiki.play.net/Script_Bigshot", :colspan => 2, :alignment => :left }]
2663+
2664+
table = Terminal::Table.new :title => "#{name.capitalize} Help v#{$bigshot_version}", :rows => table_rows
2665+
table.align_column(1, :right)
2666+
respond
2667+
respond table
2668+
respond
2669+
else
2670+
respond ""
2671+
respond "#############################################################################"
2672+
respond ""
2673+
respond " #{name.capitalize} Help v#{$bigshot_version}"
2674+
respond ""
2675+
respond " Modes can be combined, e.g. #{$lich_char}#{name} bounty quick"
2676+
respond "------------------------------------------------------------"
2677+
respond ""
2678+
rows.each do |left, right|
2679+
if left == :separator
2680+
respond ""
2681+
else
2682+
respond " #{left.to_s.ljust(38)}#{right}"
2683+
end
2684+
end
2685+
respond ""
2686+
respond " Full documentation: https://gswiki.play.net/Script_Bigshot"
2687+
respond ""
2688+
respond "#############################################################################"
2689+
respond ""
2690+
end
2691+
end
2692+
2693+
# Prints the debug-logging command reference.
2694+
#
2695+
# @return [void]
2696+
# @see help
26002697
def self.debug_help
26012698
if defined?(Terminal)
26022699
rows = []
@@ -8648,7 +8745,9 @@ if Script.current.vars.any? { |var| var =~ /single|once/i }
86488745
$bigshot_single = true
86498746
end
86508747

8651-
if (Script.current.vars[1].nil? || Script.current.vars[1] =~ /solo|bounty|quick|single|once/i)
8748+
if (Script.current.vars[1] =~ /\Ahelp\z/i)
8749+
Bigshot.help
8750+
elsif (Script.current.vars[1].nil? || Script.current.vars[1] =~ /solo|bounty|quick|single|once/i)
86528751
if Script.current.vars[1] =~ /quick/i
86538752
$bigshot_quick = true
86548753
end
@@ -9034,4 +9133,7 @@ elsif (Script.current.vars[1] =~ /tail|follow|link/i)
90349133
Script.self.kill
90359134
end
90369135
end
9136+
else
9137+
Lich::Messaging.msg("yellow", " Unknown option: #{Script.current.vars[1]}")
9138+
Bigshot.help
90379139
end

0 commit comments

Comments
 (0)