lib/sxmrb.rb in sxmrb-0.2.0 vs lib/sxmrb.rb in sxmrb-0.2.1
- old
+ new
@@ -45,21 +45,17 @@
# A newline-separated list of items is read from standard input.
# The selected item is printed to standard output.
#
# @example
# file = (sh('ls') | menu(prompt: 'File?')).to_s.chomp
- def menu(prompt: nil)
- sh String.new.tap { |cmd|
- if ENV['SSH_CLIENT'] || ENV['SSH_TTY']
- cmd << 'vis-menu -i -l 18'
- else
- cmd << 'dmenu -c -i -l 18'
- sh 'sxmo_keyboard.sh open'
- end
-
- cmd << " -p #{prompt.inspect}" if prompt
- }
+ # rubocop:disable Lint/AmbiguousOperator
+ def menu(prompt: nil, options: [])
+ sh *(['sxmo_dmenu_with_kb.sh'].tap { |cmd|
+ cmd.push *options
+ cmd.push '-p', prompt if prompt
+ })
end
+ # rubocop:enable Lint/AmbiguousOperator
# Use a blank #menu to prompt for a value.
#
# @example
# value = input(prompt: 'Amount?').to_i