module Bcome::WorkspaceMenu
Public Instance Methods
item_spacing(item)
click to toggle source
# File lib/objects/modules/workspace_menu.rb, line 50 def item_spacing(item) "\s" * (menu_item_spacing_length - item.length) end
menu()
click to toggle source
# File lib/objects/modules/workspace_menu.rb, line 5 def menu print "\n\n" puts 'COMMAND MENU'.bc_cyan + "\sfor #{self.class} #{namespace}".resource_value grouped_menu_items = menu_items.group_by { |m| m[1][:group] } grouped_menu_items.each do |group_key, items| # If we're not in a console session, we filter out console only methods items = items.reject { |item| item[1][:console_only] } unless ::Bcome::System::Local.instance.in_console_session? next if items.empty? s_heading = "/ #{menu_group_names[group_key]}" print "\n\n" + tab_spacing + s_heading.upcase.bc_cyan print item_spacing(s_heading) + ("\s" * 110).to_s.bc_cyan.underline print "\n\n" print_menu_items(items) end nil end
menu_group_names()
click to toggle source
# File lib/objects/modules/workspace_menu.rb, line 62 def menu_group_names { ssh: 'Ssh', informational: 'Informational', selection: 'Selections', file: 'File & Script', navigation: 'Navigational', miscellany: 'Miscellaneous', command_list: 'Command lists' } end
menu_item_spacing_length()
click to toggle source
# File lib/objects/modules/workspace_menu.rb, line 54 def menu_item_spacing_length 16 end
menu_items()
click to toggle source
# File lib/objects/modules/workspace_menu.rb, line 74 def menu_items { routes: { description: 'Print SSH routing tree', console_only: false, group: :informational }, ls: { description: 'list all available namespaces', console_only: false, group: :informational }, lsa: { description: 'list all active namespaces', console_only: true, group: :informational }, workon: { description: 'work on specific namespaces only, inactivating all others from this selection', usage: 'workon identifier1, identifier2 ...', console_only: true, group: :selection }, disable: { description: 'remove a namespace from this selection', usage: 'disable identifier1, identifier2 ...', console_only: true, group: :selection }, enable: { description: 're-enable a namespace within this selection', usage: 'enable identifier1, identifier2 ...', console_only: true, group: :selection }, enable!: { description: 'enable all namespaces within this selection', console_only: true, group: :selection }, disable!: { description: 'disable all namespaces within this selection', console_only: true, group: :selection }, run: { description: 'execute a command to be run over ssh against all active namespaces', usage: "run 'command1', 'command2', ...", console_only: false, terminal_usage: "run 'command1' 'command2' ...", group: :ssh }, interactive: { description: 'enter an interactive command session for all active namespaces', console_only: false, group: :ssh }, tree: { description: 'print a tree view for all namespaces and their sub-namespaces', console_only: false, group: :informational }, ping: { description: 'ping all namespaces to test connectivity', console_only: false, group: :ssh }, put: { description: 'upload a file or directory using scp', usage: "put 'local/path','remote/path'", console_only: false, terminal_usage: "put 'local/path' 'remote/path'", group: :file }, put_str: { description: 'Write a file /to/remote/path from a string', usage: 'put_str "string" "remote/path"', console_only: false, terminal_usage: "put_str '<file contents>', 'remote/path'", group: :file }, rsync: { description: 'upload a file or directory using rsync (faster)', usage: "rsync 'local/path','remote/path'", console_only: false, terminal_usage: "rsync 'local/path' 'remote/path'", group: :file }, cd: { description: 'enter a console session for a child namespace from this selection', usage: 'cd identifier', console_only: true, group: :navigation }, quit: { description: 'Quit out of bcome', usage: 'quit', console_only: true, group: :navigation }, back: { description: 'Go back up a namespace, or quit', usage: 'back', console_only: true, group: :navigation }, meta: { description: 'Print out all metadata related to this node', group: :informational }, registry: { description: 'List all user defined commands present in your registry, and available to this namespace', console_only: false, group: :command_list }, menu: { description: 'List all available commands', console_only: false, group: :command_list }, execute_script: { description: 'execute a bash script', console_only: false, usage: 'execute_script "script_name"', terminal_usage: 'execute_script script_name', group: :ssh } } end
mode()
click to toggle source
# File lib/objects/modules/workspace_menu.rb, line 46 def mode ::Bcome::System::Local.instance.in_console_session? ? 'Console' : 'Terminal' end
print_menu_items(items)
click to toggle source
# File lib/objects/modules/workspace_menu.rb, line 26 def print_menu_items(items) items.each_with_index do |item, _index| key = item[0] config = item[1] next if !::Bcome::System::Local.instance.in_console_session? && config[:console_only] puts tab_spacing + key.to_s.resource_key + item_spacing(key) + (config[:description]).to_s.resource_value if config[:usage] || config[:terminal_usage] usage_string = if ::Bcome::System::Local.instance.in_console_session? config[:usage] else "bcome #{keyed_namespace.empty? ? '' : "#{keyed_namespace}:"}#{config[:terminal_usage]}" end puts tab_spacing + ("\s" * menu_item_spacing_length) + 'usage: '.instructional + usage_string end puts "\n" end end
tab_spacing()
click to toggle source
# File lib/objects/modules/workspace_menu.rb, line 58 def tab_spacing "\s" * 3 end