linen 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/linen.rb +2 -2
- data/lib/linen/cli.rb +21 -2
- data/lib/linen/command.rb +12 -1
- data/lib/linen/plugin.rb +3 -2
- metadata +1 -1
data/lib/linen.rb
CHANGED
data/lib/linen/cli.rb
CHANGED
@@ -108,8 +108,27 @@ class Linen::CLI
|
|
108
108
|
workspace = Linen::Workspace.new
|
109
109
|
results = command.validate_arguments( args )
|
110
110
|
|
111
|
-
|
112
|
-
command.
|
111
|
+
input = ''
|
112
|
+
if command.requires_confirmation?
|
113
|
+
puts "Running '#{plugin.short_name} #{command.name}' with arguments:"
|
114
|
+
|
115
|
+
puts results.map { |arg, value|
|
116
|
+
next unless value
|
117
|
+
"#{arg}: #{value}"
|
118
|
+
}.join( "\n" )
|
119
|
+
|
120
|
+
while input !~ /^(y|n)/i
|
121
|
+
input = Readline.readline( "\nContinue [y/N]? ")
|
122
|
+
input = "n" if input == ''
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
if input =~ /^y/i
|
127
|
+
puts # blank line
|
128
|
+
|
129
|
+
workspace.add_values( results )
|
130
|
+
command.execute( workspace )
|
131
|
+
end
|
113
132
|
end
|
114
133
|
|
115
134
|
|
data/lib/linen/command.rb
CHANGED
@@ -8,6 +8,8 @@
|
|
8
8
|
##############################################################
|
9
9
|
|
10
10
|
class Linen::Plugin::Command
|
11
|
+
attr_reader :name
|
12
|
+
|
11
13
|
def initialize( plugin, name, &block )
|
12
14
|
@plugin = plugin
|
13
15
|
@name = name
|
@@ -83,6 +85,11 @@ class Linen::Plugin::Command
|
|
83
85
|
def action( &block )
|
84
86
|
@action_proc = block
|
85
87
|
end
|
88
|
+
|
89
|
+
|
90
|
+
def require_confirmation
|
91
|
+
@require_confirmation = true
|
92
|
+
end
|
86
93
|
|
87
94
|
|
88
95
|
##################
|
@@ -100,7 +107,11 @@ class Linen::Plugin::Command
|
|
100
107
|
# exception string. :P
|
101
108
|
raise "Something has happened!"
|
102
109
|
end
|
103
|
-
|
110
|
+
|
111
|
+
|
112
|
+
def requires_confirmation?
|
113
|
+
@require_confirmation
|
114
|
+
end
|
104
115
|
|
105
116
|
###########
|
106
117
|
private #
|
data/lib/linen/plugin.rb
CHANGED
@@ -18,8 +18,9 @@ class Linen::Plugin
|
|
18
18
|
end
|
19
19
|
|
20
20
|
|
21
|
-
def self::short_name
|
22
|
-
|
21
|
+
def self::short_name( short_name = nil )
|
22
|
+
@short_name = short_name if short_name
|
23
|
+
return @short_name || self.to_s.downcase.gsub( /plugin$/, '' )
|
23
24
|
end
|
24
25
|
|
25
26
|
|