-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added examples for
CommandKit::Interactive
.
- Loading branch information
1 parent
54e587f
commit c434621
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |