class Fantassh::Application
Public Class Methods
bash_history()
click to toggle source
# File lib/fantassh/application.rb, line 72 def bash_history BashHistory.new end
entries()
click to toggle source
# File lib/fantassh/application.rb, line 68 def entries Entries.new end
exclude(entry)
click to toggle source
# File lib/fantassh/application.rb, line 64 def exclude(entry) entries.exclude([entry]) end
history()
click to toggle source
# File lib/fantassh/application.rb, line 76 def history History.new end
last()
click to toggle source
# File lib/fantassh/application.rb, line 55 def last last = history.last if last run_ssh_command(last) else puts "There is no history entry just yet!" end end
list()
click to toggle source
# File lib/fantassh/application.rb, line 44 def list entries.add(bash_history.entries) selected_entry = `echo '#{entries.all.join("\n")}' | selecta` # in case selecta receives ctrl+c we don't proceed unless selected_entry.empty? history.add(selected_entry) run_ssh_command(selected_entry) end end
run(argv = ARGV)
click to toggle source
# File lib/fantassh/application.rb, line 9 def run(argv = ARGV) Slop.parse(argv, help: true) do on '-v', '--version', 'Print the program version.' do puts "#{File.basename($0)} v#{Fantassh::VERSION}" exit end # default, runs when called without arguments run do Fantassh::Application.list end command :last do banner "Usage: #{File.basename($0)} last" run do Fantassh::Application.last end end command :exclude do banner "Usage: #{File.basename($0)} exclude <ssh command>" run do |opts, args| if args.empty? puts help exit end Fantassh::Application.exclude(args.join(' ')) end end end end
run_ssh_command(argument)
click to toggle source
# File lib/fantassh/application.rb, line 80 def run_ssh_command(argument) # indent by whitespace so it doesn't show up in the history exec " ssh #{argument}" end