tabtab 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,4 +1,11 @@
1
- == 0.0.1 2008-11-12
1
+ == 0.91 2008-12-29
2
+
3
+ * Uses ENV['COMP_LINE'] for full current line if available
4
+ * New completions: rubyforge, rake
5
+ * Bugs fixed:
6
+ * Only install completions from latest version of each gem
7
+
8
+ == 0.9.0 2008-11-12
2
9
 
3
10
  * 1 major enhancement:
4
11
  * Initial release
data/Manifest.txt CHANGED
@@ -21,7 +21,6 @@ features/steps/env.rb
21
21
  features/steps/gems.rb
22
22
  features/steps/shells.rb
23
23
  lib/dev_definitions/gem.rb
24
- lib/dev_definitions/rake.rb
25
24
  lib/dev_definitions/script-generate.rb
26
25
  lib/dev_definitions/script-server.rb
27
26
  lib/install_tabtab/cli.rb
@@ -44,6 +43,7 @@ lib/tabtab_definitions/cucumber.rb
44
43
  lib/tabtab_definitions/github.rb
45
44
  lib/tabtab_definitions/newgem.rb
46
45
  lib/tabtab_definitions/rails.rb
46
+ lib/tabtab_definitions/rake.rb
47
47
  lib/tabtab_definitions/rubyforge.rb
48
48
  script/console
49
49
  script/destroy
data/README.rdoc CHANGED
@@ -12,7 +12,7 @@ of a command-line application or a target file or folder. Its possible to
12
12
  provide your own completions for applications: git comes with bash shell completions,
13
13
  and the fish shell includes a library of completions for many applications.
14
14
 
15
- == QUICK START/TRIAL ME:
15
+ === Quick Start/Trial Me:
16
16
 
17
17
  The tabtab gem comes with some pre-defined completions for some popular applications
18
18
  that benefit from completions: rails, newgem, cucumber, github (and its alias gh).
@@ -25,12 +25,14 @@ It takes 2 minutes to trial this project and see if you like it:
25
25
 
26
26
  rails -d TABTAB
27
27
 
28
+ sudo gem install defunkt-github -s http://gems.github.com
28
29
  cd project/hosted/on/github/with/contributors/like/rails/or/rspec
30
+
29
31
  github TABTAB
30
32
  gh netTAB feTAB
31
33
  gh netTAB web TABTAB
32
34
 
33
- It just works.
35
+ It just works. Flags. Commands. Intelligent values. Aliases. Ooh yeah.
34
36
 
35
37
  Now, add 'source ~/.tabtab.bash' to your .bash_profile so you have this awesomeness in all your
36
38
  terminal shells.
@@ -343,6 +345,60 @@ please let me know. I have some cucumber scenarios ready and waiting for your he
343
345
  Currently, tabtab works with the bash shell, though it is designed to be
344
346
  shell agnostic.
345
347
 
348
+ == KNOWN ISSUES/LIMITATIONS & ARCHITECTURE OVERVIEW:
349
+
350
+ Pride and ego mean this section goes at the bottom of the readme... this section includes the known
351
+ issues and limitations of TabTab due to current architectural decisions, the aim of being
352
+ shell agnostic whilst initially only implementing TabTab for bash, and DSL challenges in
353
+ attempting to support all possible command-line app APIs with a sexy, small DSL for describing
354
+ auto-completions.
355
+
356
+ === Cannot support rake/sake/cap colon-separated completions
357
+
358
+ This will be fixed soon. I only just discovered this deficiency.
359
+
360
+ Auto-completion for rake/sake/cap - when I get it working - will allow you to tab
361
+ through the namespacing across the colons. E.g. 'rake db:test:' and tabtab will show
362
+ all the tasks within this namespace. That's what it should do. That's what all the
363
+ current implementations of auto-completion do before tabtab. But with tabtab (currently)
364
+ it can't do it. I suck. But here's the reason and the fix.
365
+
366
+ To fix it requires rewriting the guts of the tabtab application to use $COMP_LINE
367
+ environment variable instead of the current, previous token.
368
+
369
+ Currently tabtab works by passing the current and previous token in the current command
370
+ line string around. But bash isn't coping with colon's correctly. If you tabtab after
371
+ a colon it just ignores the characters before it.
372
+
373
+ So, I'll abandon the whole mechanism of (current, previous) tokens and use the $COMP_LINE
374
+ variable and manually parse it into tokens via the Shellwords.shellwords function.
375
+
376
+ === Nested intelligent lists
377
+
378
+ Some applications may want to have multiple auto-completed values in a row, with the 2nd value's list
379
+ being dependent upon the value of the first. For example, the 'rubyforge add_release' command takes
380
+ four more arguments: group_id, package_id, release_name, userfile. The first two - group_id and package_id -
381
+ are from known lists of values. The values available for package_id are dependent upon the group_id value.
382
+ This is a nested list, and currently TabTab probably can't do them.
383
+
384
+ Currently intelligent, dynamic lists of completable values are defined via 'default' blocks - either blocks
385
+ passed to #flag or #command calls, or via #default calls. I guess to support nested lists you'd need
386
+ nested default blocks. Not sure.
387
+
388
+ Or perhaps we need specific syntax to support commands with 2+ arguments.
389
+
390
+ TabTab::Definition.register('rubyforge') do |c|
391
+ c.command(:add_release, 1) { list_of_rubyforge_group_names }
392
+ c.command(:add_release, 2) { |group_id| list_of_rubyforge_package_names_in(group_id) }
393
+ end
394
+
395
+ In this pseudo code we redefine the :add_release command for each nested argument. The 2nd+ argument
396
+ is passed the completed values from the previous arguments of the command so they
397
+ can filter their lists as appropriate. Might work.
398
+
399
+ Of course, the second argument (1, 2, ...) would be optional and only required if you were trying
400
+ to describe a nested list of interdependent values.
401
+
346
402
  == SOURCE:
347
403
 
348
404
  The source for this project is at http://github.com/drnic/tabtab
@@ -354,11 +410,21 @@ Using git, you can clone the project, run its tests and install it:
354
410
  rake
355
411
  rake install_gem
356
412
 
357
- == SPONSOR
413
+ == ACKNOWLEDGEMENT and SPONSOR
414
+
415
+ I wrote most of this at Railscamp #4 in Adelaide, between 13th and 17th of November 2008. Railscamps
416
+ are so awesome. They are a conference without the conference part. Coding, lightning talks, alcohol,
417
+ and guitar hero. Thanks to all the people I demo'd tabtab during its development, for their thoughts
418
+ on the final DSL, and finally for helping give TabTab a name.
419
+
420
+ After Railscamp, I kept coding tabtab instead of doing proper work. Therefore this project has
421
+ a sponsor:
358
422
 
359
423
  * Mocra - the premier iPhone/Rails consultancy
360
424
  * http://mocra.com
361
425
 
426
+ Like TabTab? Don't donate money, just hire us for your next Rails or iPhone party.
427
+
362
428
  == LICENSE:
363
429
 
364
430
  (The MIT License)
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- %w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
1
+ %w[rubygems rake rake/clean fileutils newgem].each { |f| require f }
2
2
  require File.dirname(__FILE__) + '/lib/tabtab'
3
3
 
4
4
  # Generate all the Rake tasks
@@ -79,7 +79,7 @@ module InstallTabTab
79
79
  end
80
80
 
81
81
  def find_gems_with_definition_files
82
- Gem.all_load_paths.inject([]) do |mem, path|
82
+ Gem.latest_load_paths.inject([]) do |mem, path|
83
83
  root = path.gsub(/(lib|bin)$/,'')
84
84
  mem << root unless mem.include?(root)
85
85
  mem
@@ -87,14 +87,14 @@ module InstallTabTab
87
87
  common_file = Dir[File.join(path, "**", "tabtab_definitions.rb")].reject { |tabtab_path| tabtab_path =~ /(spec|test)/ }.first
88
88
  gem_name = nil
89
89
  unless common_file.nil? || common_file.empty?
90
- gem_name = common_file.match(/\/([^\/]*)-\d+.\d+.\d+\/lib\//)[1]
90
+ gem_name = common_file.match(/\/([^\/]*)-\d+(\.\d+)+\/lib\//)[1]
91
91
  TabTab::Definition.clear
92
92
  load common_file
93
93
  mem << { :gem_name => gem_name, :app_names => TabTab::Definition.app_names }
94
94
  end
95
95
  files = Dir[File.join(path, "**", "tabtab_definitions", "**", "*.rb")].reject { |tabtab_path| tabtab_path =~ /(spec|test)/ }
96
96
  if files && files.size > 0
97
- gem_path, gem_name = files.first.match(/^(.*\/([^\/]*)-\d+.\d+.\d+)/)[1..2]
97
+ gem_path, gem_name = files.first.match(/^(.*\/([^\/]*)-\d+(\.\d+)+)/)[1..2]
98
98
  files.each do |file|
99
99
  TabTab::Definition.clear
100
100
  load file
data/lib/tabtab.rb CHANGED
@@ -2,7 +2,7 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  module TabTab
5
- VERSION = '0.9.0'
5
+ VERSION = '0.9.1'
6
6
  end
7
7
 
8
8
  require 'tabtab/local_config'
data/lib/tabtab/cli.rb CHANGED
@@ -16,11 +16,7 @@ module TabTab
16
16
 
17
17
  def execute(stdout, arguments=[])
18
18
  @stdout = stdout
19
- # require "shellwords"
20
- # @full_line = ENV['COMP_LINE']
21
- # @full_line_argv = Shellwords.shellwords(@full_line)
22
- @app_name, @current_token, @previous_token = arguments[-3..-1]
23
- parse_options(arguments[0..-4])
19
+ extract_tokens_and_parse_options(arguments)
24
20
  load_global_config
25
21
  if options[:external]
26
22
  process_external
@@ -33,6 +29,22 @@ module TabTab
33
29
  end
34
30
  end
35
31
 
32
+ # parses the incoming tokens either via ENV['COMP_LINE'] or tokens from ARGV
33
+ def extract_tokens_and_parse_options(arguments)
34
+ if ENV['COMP_LINE']
35
+ require "shellwords"
36
+ line = ENV['COMP_LINE']
37
+ words = Shellwords.shellwords(line)
38
+ words << "" if line.split("")[-1] == " "
39
+ @app_name = words[0]
40
+ @previous_token, @current_token = words[-2..-1]
41
+ parse_options(arguments)
42
+ else
43
+ @app_name, @current_token, @previous_token = arguments[-3..-1]
44
+ parse_options(arguments[0..-4])
45
+ end
46
+ end
47
+
36
48
  def parse_options(arguments)
37
49
  @options = {}
38
50
  OptionParser.new do |opts|
@@ -106,7 +106,7 @@ class TabTab::Definition::Base
106
106
  def yield_definition_block
107
107
  if definition_block.nil?
108
108
  return
109
- elsif definition_block.arity == -1
109
+ elsif definition_block.arity == -1 || definition_block.arity == 0
110
110
  # these blocks return a result/do lots of work - don't run them now
111
111
  elsif definition_block.arity == 1
112
112
  definition_block.call self
@@ -15,10 +15,10 @@ module TabTab::Definition
15
15
  end
16
16
 
17
17
  def yield_result_block
18
- if definition_block.arity == -1
18
+ if definition_block.arity == -1 || definition_block.arity == 0
19
19
  definition_block.call
20
20
  elsif definition_block.arity == 1
21
- definition_block.call(parent.current_token)
21
+ definition_block.call(self)
22
22
  else
23
23
  raise TabTab::Definition::InvalidDefinitionBlockArguments
24
24
  end
@@ -0,0 +1,20 @@
1
+ TabTab::Definition.register('rake', :import => true) do |c|
2
+ def rake_silent_tasks
3
+ # TODO cache per directory
4
+ `rake --silent --tasks`
5
+ end
6
+ # c.cache :rake_silent_tasks, :per => :folder
7
+
8
+ c.default do |cmd|
9
+ next [] if cmd.current_token.nil? # TODO why are these blocks invoked twice? (1st on setup, 2nd for parsing)
10
+ tasks = (rake_silent_tasks.split("\n")[1..-1] || []).map { |line| line.split[1] }
11
+ if cmd.current_token =~ /^([-\w:]+:)/
12
+ upto_last_colon = Regexp.escape($1)
13
+ tasks = tasks.select { |task| /^#{Regexp.escape cmd.current_token}/ =~ task }
14
+ tasks.map! { |task| task.gsub(/#{Regexp.escape upto_last_colon}/, '') }
15
+ end
16
+ tasks
17
+ end
18
+ c.flags :silence, :s
19
+ c.flags :trace, :t
20
+ end
@@ -1,17 +1,29 @@
1
1
  TabTab::Definition.register('rubyforge', :import => true) do |c|
2
+ def groups
3
+ require "yaml"
4
+ config = YAML.load(File.read(File.expand_path("~/.rubyforge/auto-config.yml")))
5
+ config["group_ids"].keys
6
+ end
7
+
2
8
  def projects
3
- []
9
+ require "yaml"
10
+ config = YAML.load(File.read(File.expand_path("~/.rubyforge/auto-config.yml")))
11
+ config["project_ids"].keys
4
12
  end
13
+
5
14
  c.command :setup
15
+ c.command :help
6
16
  c.command(:config) { projects }
7
17
  c.command :names
8
18
  c.command :login do |login|
9
19
  login.flag :username
10
20
  login.flag :password
11
21
  end
12
- c.command :create_package
13
- c.command :add_release
14
- c.command :add_file
15
- c.command :delete_package
22
+ # TODO - need nesting of default blocks: rubyforge create_package group_id package_name
23
+ # This will probably require access to $COMP_LINE
24
+ c.command(:create_package) { groups }
25
+ c.command(:add_release) { groups }
26
+ c.command(:add_file) { groups }
27
+ c.command(:delete_package) { groups }
16
28
  end
17
29
 
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Dr Nic Williams"]
9
- s.date = %q{2008-11-23}
9
+ s.date = %q{2008-12-29}
10
10
  s.default_executable = %q{test_app}
11
11
  s.description = %q{Multiple CLI apps + in-built autocompletions}
12
12
  s.email = ["drnicwilliams@gmail.com"]
@@ -25,14 +25,14 @@ Gem::Specification.new do |s|
25
25
  s.specification_version = 2
26
26
 
27
27
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
- s.add_development_dependency(%q<newgem>, [">= 1.1.0"])
28
+ s.add_development_dependency(%q<newgem>, [">= 1.2.3"])
29
29
  s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
30
30
  else
31
- s.add_dependency(%q<newgem>, [">= 1.1.0"])
31
+ s.add_dependency(%q<newgem>, [">= 1.2.3"])
32
32
  s.add_dependency(%q<hoe>, [">= 1.8.0"])
33
33
  end
34
34
  else
35
- s.add_dependency(%q<newgem>, [">= 1.1.0"])
35
+ s.add_dependency(%q<newgem>, [">= 1.2.3"])
36
36
  s.add_dependency(%q<hoe>, [">= 1.8.0"])
37
37
  end
38
38
  end
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Dr Nic Williams"]
9
- s.date = %q{2008-11-23}
9
+ s.date = %q{2008-12-29}
10
10
  s.default_executable = %q{test_app}
11
11
  s.description = %q{Simple CLI app + in-built autocompletions}
12
12
  s.email = ["drnicwilliams@gmail.com"]
@@ -25,14 +25,14 @@ Gem::Specification.new do |s|
25
25
  s.specification_version = 2
26
26
 
27
27
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
- s.add_development_dependency(%q<newgem>, [">= 1.1.0"])
28
+ s.add_development_dependency(%q<newgem>, [">= 1.2.3"])
29
29
  s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
30
30
  else
31
- s.add_dependency(%q<newgem>, [">= 1.1.0"])
31
+ s.add_dependency(%q<newgem>, [">= 1.2.3"])
32
32
  s.add_dependency(%q<hoe>, [">= 1.8.0"])
33
33
  end
34
34
  else
35
- s.add_dependency(%q<newgem>, [">= 1.1.0"])
35
+ s.add_dependency(%q<newgem>, [">= 1.2.3"])
36
36
  s.add_dependency(%q<hoe>, [">= 1.8.0"])
37
37
  end
38
38
  end
@@ -6,7 +6,7 @@ describe InstallTabTab::CLI, "with --development CLI flag" do
6
6
  ENV['HOME'] = '/tmp/some/home'
7
7
  dev_bin = File.expand_path(File.dirname(__FILE__) + "/../bin/tabtab")
8
8
  @cli = InstallTabTab::CLI.new
9
- Gem.expects(:all_load_paths).returns([])
9
+ Gem.expects(:latest_load_paths).returns([])
10
10
  @cli.expects(:config).returns({"external" => %w[test_app]}).at_least(2)
11
11
  File.expects(:open).with('/tmp/some/home/.tabtab.bash', 'w').returns(mock do
12
12
  expects(:<<).with("complete -o default -C '#{dev_bin} --external' test_app\n")
@@ -24,7 +24,7 @@ describe InstallTabTab::CLI, "with --external app flag" do
24
24
  before(:each) do
25
25
  ENV['HOME'] = '/tmp/some/home'
26
26
  @cli = InstallTabTab::CLI.new
27
- Gem.expects(:all_load_paths).returns([])
27
+ Gem.expects(:latest_load_paths).returns([])
28
28
  @stdout_io = StringIO.new
29
29
  end
30
30
 
@@ -74,7 +74,7 @@ describe InstallTabTab::CLI, "with --gem GEM_NAME app flag" do
74
74
  TabTab::Definition.clear
75
75
  @cli = InstallTabTab::CLI.new
76
76
  @cli.expects(:config).returns({}).at_least(1)
77
- Gem.expects(:all_load_paths).returns(['/gems/gem_with_tabtabs-1.0.0/lib'])
77
+ Gem.expects(:latest_load_paths).returns(['/gems/gem_with_tabtabs-1.0.0/lib'])
78
78
  Dir.expects(:[]).with('/gems/gem_with_tabtabs-1.0.0/**/tabtab_definitions/**/*.rb').returns([])
79
79
  Dir.expects(:[]).with('/gems/gem_with_tabtabs-1.0.0/**/tabtab_definitions.rb').returns(['/gems/gem_with_tabtabs-1.0.0/lib/tabtab_definitions.rb'])
80
80
  @cli.expects(:load).with('/gems/gem_with_tabtabs-1.0.0/lib/tabtab_definitions.rb').returns(true)
@@ -98,7 +98,7 @@ describe InstallTabTab::CLI, "with --gem GEM_NAME/PATH flag" do
98
98
  TabTab::Definition.clear
99
99
  @cli = InstallTabTab::CLI.new
100
100
  @cli.expects(:config).returns({}).at_least(1)
101
- Gem.expects(:all_load_paths).returns(['/gems/gem_with_tabtabs-1.0.0/lib'])
101
+ Gem.expects(:latest_load_paths).returns(['/gems/gem_with_tabtabs-1.0.0/lib'])
102
102
  Dir.expects(:[]).with('/gems/gem_with_tabtabs-1.0.0/**/tabtab_definitions.rb').returns([])
103
103
  Dir.expects(:[]).with('/gems/gem_with_tabtabs-1.0.0/**/tabtab_definitions/**/*.rb').returns(['/gems/gem_with_tabtabs-1.0.0/lib/tabtab_definitions/tabtabbed_app.rb'])
104
104
  @cli.expects(:load).with('/gems/gem_with_tabtabs-1.0.0/lib/tabtab_definitions/tabtabbed_app.rb').returns(true)
@@ -123,7 +123,7 @@ describe InstallTabTab::CLI, "with --file FILE_NAME app flag" do
123
123
  ENV['HOME'] = '/tmp/some/home'
124
124
  @cli = InstallTabTab::CLI.new
125
125
  @cli.expects(:config).returns({'file' => {'/path/to/definition.rb' => 'some_app'}}).at_least(2)
126
- Gem.expects(:all_load_paths).returns([])
126
+ Gem.expects(:latest_load_paths).returns([])
127
127
  File.expects(:open).with('/tmp/some/home/.tabtab.bash', 'w').returns(mock do
128
128
  expects(:<<).with("complete -o default -C 'tabtab --file /path/to/definition.rb' some_app\n")
129
129
  expects(:close)
@@ -143,3 +143,44 @@ describe TabTab::CLI, "--file flag" do
143
143
  end
144
144
  end
145
145
 
146
+ describe TabTab::CLI, "extracting tokens using ENV['COMP_LINE'] via extract_tokens_and_parse_options" do
147
+ describe "with no tokens" do
148
+ before(:each) do
149
+ ENV['COMP_LINE'] = "myapp "
150
+ @cli = TabTab::CLI.new
151
+ @cli.extract_tokens_and_parse_options([])
152
+ end
153
+
154
+ it "should setup app_name" do
155
+ @cli.app_name.should == "myapp"
156
+ end
157
+
158
+ it "should setup current_token" do
159
+ @cli.current_token.should == ""
160
+ end
161
+
162
+ it "should setup previous_token" do
163
+ @cli.previous_token.should == "myapp"
164
+ end
165
+ end
166
+
167
+ describe "mid-way through a token" do
168
+ before(:each) do
169
+ ENV['COMP_LINE'] = "rake db:"
170
+ @cli = TabTab::CLI.new
171
+ @cli.extract_tokens_and_parse_options([])
172
+ end
173
+
174
+ it "should setup app_name" do
175
+ @cli.app_name.should == "rake"
176
+ end
177
+
178
+ it "should setup current_token" do
179
+ @cli.current_token.should == "db:"
180
+ end
181
+
182
+ it "should setup previous_token" do
183
+ @cli.previous_token.should == "rake"
184
+ end
185
+ end
186
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tabtab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dr Nic Williams
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-23 00:00:00 +10:00
12
+ date: 2008-12-29 00:00:00 +10:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.1.0
23
+ version: 1.2.3
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: cucumber
@@ -83,7 +83,6 @@ files:
83
83
  - features/steps/gems.rb
84
84
  - features/steps/shells.rb
85
85
  - lib/dev_definitions/gem.rb
86
- - lib/dev_definitions/rake.rb
87
86
  - lib/dev_definitions/script-generate.rb
88
87
  - lib/dev_definitions/script-server.rb
89
88
  - lib/install_tabtab/cli.rb
@@ -106,6 +105,7 @@ files:
106
105
  - lib/tabtab_definitions/github.rb
107
106
  - lib/tabtab_definitions/newgem.rb
108
107
  - lib/tabtab_definitions/rails.rb
108
+ - lib/tabtab_definitions/rake.rb
109
109
  - lib/tabtab_definitions/rubyforge.rb
110
110
  - script/console
111
111
  - script/destroy
@@ -1,23 +0,0 @@
1
- TabTab::Definition.register('rake', :import => true) do |c|
2
- def rake_silent_tasks
3
- if File.exists?(dotcache = File.join(File.expand_path('~'), ".raketabs-#{Dir.pwd.hash}"))
4
- File.read(dotcache)
5
- else
6
- tasks = `rake --silent --tasks`
7
- File.open(dotcache, 'w') { |f| f.puts tasks }
8
- tasks
9
- end
10
- end
11
-
12
- c.default do |current|
13
- tasks = (rake_silent_tasks.split("\n")[1..-1] || []).map { |line| line.split[1] }
14
- if current =~ /^([-\w:]+:)/
15
- upto_last_colon = $1
16
- p upto_last_colon
17
- tasks = tasks.map { |t| (t =~ /^#{Regexp.escape upto_last_colon}([-\w:]+)$/) ? "#{$1}" : t }
18
- end
19
- tasks
20
- end
21
- c.flags :silence, :s
22
- c.flags :trace, :t
23
- end