lib/gitlab/shell.rb in gitlab-4.5.0 vs lib/gitlab/shell.rb in gitlab-4.6.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
require 'gitlab'
require 'gitlab/help'
require 'gitlab/cli_helpers'
require 'gitlab/shell_history'
require 'readline'
@@ -13,11 +15,11 @@
def start
trap('INT') { quit_shell } # capture ctrl-c
setup
- while buffer = Readline.readline('gitlab> ')
+ while (buffer = Readline.readline('gitlab> '))
begin
parse_input buffer
@arguments.map! { |arg| symbolize_keys(yaml_load(arg)) }
@@ -32,11 +34,11 @@
history << buffer
data = execute command, arguments
output_table command, arguments, data
end
- rescue => e
+ rescue StandardError => e
puts e.message
end
end
quit_shell # save history if user presses ctrl-d
@@ -44,11 +46,11 @@
def parse_input(buffer)
buf = Shellwords.shellwords(buffer)
@command = buf.shift
- @arguments = buf.count > 0 ? buf : []
+ @arguments = buf.count.positive? ? buf : []
end
def setup
history.load
@@ -60,10 +62,10 @@
def completion
proc { |str| actions.map(&:to_s).grep(/^#{Regexp.escape(str)}/) }
end
# Execute a given command with arguements
- def execute(cmd=command, args=arguments)
+ def execute(cmd = command, args = arguments)
raise "Unknown command: #{cmd}. See the 'help' for a list of valid commands." unless actions.include?(cmd.to_sym)
confirm_command(cmd)
gitlab_helper(cmd, args)
end