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 CHANGED
@@ -18,8 +18,8 @@ require 'string_extensions'
18
18
 
19
19
 
20
20
  module Linen
21
- VERSION = "0.3.0"
22
- SVNRev = %q$Rev: 71 $
21
+ VERSION = "0.3.1"
22
+ SVNRev = %q$Rev: 84 $
23
23
 
24
24
 
25
25
  def self::plugins
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
- workspace.add_values( results )
112
- command.execute( workspace )
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
- self.to_s.downcase.gsub /plugin$/, ''
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
 
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: linen
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.3.0
6
+ version: 0.3.1
7
7
  date: 2007-09-10 00:00:00 -07:00
8
8
  summary: Linen - A pluggable command-line interface library
9
9
  require_paths: