Skip to content

Commit

Permalink
Added examples for CommandKit::Interactive.
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Jun 20, 2024
1 parent 54e587f commit c434621
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions examples/interactive.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env ruby

$LOAD_PATH.unshift(File.expand_path('../../lib',__FILE__))
require 'command_kit/command'
require 'command_kit/interactive'

class InteractiveCmd < CommandKit::Command

include CommandKit::Interactive

description 'Demonstrates interactive prompt input'

def run
you_entered = ->(result) {
puts "You entered: #{result.inspect}"
puts
}

you_entered[ask("Single-line input")]
you_entered[ask_secret("Secret input")]
you_entered[ask_yes_or_no("Yes or no prompt")]
you_entered[ask_multiple_choice("Multiple choice", %w[Red Green Blue])]
you_entered[ask_multiline('Multi-line comment 1')]
end

end

if __FILE__ == $0
InteractiveCmd.start
end

0 comments on commit c434621

Please sign in to comment.