check_commands -> filter_commands

bug/bundler_fix
Tim 2017-06-06 13:56:38 +08:00
parent 7625d36c1c
commit e9c9c852ab
7 changed files with 8 additions and 16 deletions

View File

@ -52,18 +52,10 @@ module Console::CommandDispatcher
# #
# Returns the commands that meet the requirements # Returns the commands that meet the requirements
# #
def check_commands(all, reqs=nil) def filter_commands(all, reqs)
all.delete_if do |cmd, _desc| all.delete_if do |cmd, _desc|
del = false reqs[cmd].any? { |req| !client.commands.include?(req) }
reqs[cmd].each do |req|
next if client.commands.include? req
del = true
break
end
del
end end
all
end end
# #

View File

@ -52,7 +52,7 @@ class Console::CommandDispatcher::Android
'set_audio_mode' => ['android_set_audio_mode'], 'set_audio_mode' => ['android_set_audio_mode'],
'wakelock' => ['android_wakelock'], 'wakelock' => ['android_wakelock'],
} }
check_commands(all, reqs) filter_commands(all, reqs)
end end
def interval_collect_usage def interval_collect_usage

View File

@ -41,7 +41,7 @@ class Console::CommandDispatcher::Extapi::Adsi
"adsi_dc_enum" => [ "extapi_adsi_domain_query" ], "adsi_dc_enum" => [ "extapi_adsi_domain_query" ],
"adsi_domain_query" => [ "extapi_adsi_domain_query" ], "adsi_domain_query" => [ "extapi_adsi_domain_query" ],
} }
check_commands(all, reqs) filter_commands(all, reqs)
end end
# #

View File

@ -40,7 +40,7 @@ class Console::CommandDispatcher::Extapi::Clipboard
"clipboard_monitor_purge" => [ "extapi_clipboard_monitor_purge" ], "clipboard_monitor_purge" => [ "extapi_clipboard_monitor_purge" ],
"clipboard_monitor_stop" => [ "extapi_clipboard_monitor_stop" ], "clipboard_monitor_stop" => [ "extapi_clipboard_monitor_stop" ],
} }
check_commands(all, reqs) filter_commands(all, reqs)
end end
# #

View File

@ -31,7 +31,7 @@ class Console::CommandDispatcher::Extapi::Service
"service_query" => [ "extapi_service_query" ], "service_query" => [ "extapi_service_query" ],
"service_control" => [ "extapi_service_control" ], "service_control" => [ "extapi_service_control" ],
} }
check_commands(all, reqs) filter_commands(all, reqs)
end end
# #

View File

@ -27,7 +27,7 @@ class Console::CommandDispatcher::Extapi::Window
reqs = { reqs = {
"window_enum" => [ "extapi_window_enum" ], "window_enum" => [ "extapi_window_enum" ],
} }
check_commands(all, reqs) filter_commands(all, reqs)
end end
# #

View File

@ -31,7 +31,7 @@ class Console::CommandDispatcher::Extapi::Wmi
reqs = { reqs = {
"wmi_query" => [ "extapi_wmi_query" ], "wmi_query" => [ "extapi_wmi_query" ],
} }
check_commands(all, reqs) filter_commands(all, reqs)
end end
# #