do 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES.md +4 -0
- data/extras/completion.rb +36 -0
- data/lib/do/common.rb +4 -2
- data/lib/do/version.rb +1 -1
- metadata +5 -4
data/CHANGES.md
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# to install, add the following line to your .bash_profile or .bashrc
|
4
|
+
# complete -C ~/.do/completion -o default doit
|
5
|
+
|
6
|
+
# Rake completion will return matching rake tasks given typed text. This way
|
7
|
+
# you can auto-complete tasks as you are typing them by hitting [tab] or [tab][tab]
|
8
|
+
# This also caches the rake tasks for optimium speed
|
9
|
+
class DoCompletion
|
10
|
+
BIN = File.expand_path('../../bin/doit', __FILE__)
|
11
|
+
|
12
|
+
def initialize(command)
|
13
|
+
@command = command
|
14
|
+
end
|
15
|
+
|
16
|
+
def matches
|
17
|
+
do_tasks.select { |task| task =~ %r[^#{typed}] }.
|
18
|
+
map { |task| task.sub(typed_before_colon, '')}
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def typed
|
23
|
+
@command[/\s(.+?)$/, 1] || ''
|
24
|
+
end
|
25
|
+
|
26
|
+
def typed_before_colon
|
27
|
+
typed[/.+\:/] || ''
|
28
|
+
end
|
29
|
+
|
30
|
+
def do_tasks
|
31
|
+
`#{BIN} list`.split("\n")[1..-1].map { |line| line.split[1] }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
puts DoCompletion.new(ENV["COMP_LINE"]).matches
|
36
|
+
exit 0
|
data/lib/do/common.rb
CHANGED
@@ -33,7 +33,7 @@ task :setup do |options|
|
|
33
33
|
hrc = File.expand_path("~/.dorc")
|
34
34
|
orc = File.join(DO_PATH, 'dorc')
|
35
35
|
if File.exist?(orc)
|
36
|
-
log "Config already
|
36
|
+
log "Config already exists in your \e[1m%s\e[0m path." % DO_PATH unless options[:dependency]
|
37
37
|
else
|
38
38
|
template = <<-RUBY.gsub(/^ {6}/, '')
|
39
39
|
##
|
@@ -52,6 +52,8 @@ task :setup do |options|
|
|
52
52
|
log "\e[36mGenerated template, now you can add your config to: '%s'\e[0m" % orc
|
53
53
|
end
|
54
54
|
sh 'ln -s %s %s' % [orc, hrc] unless File.exist?(hrc)
|
55
|
+
log "To enable autocompletion add to your \e[1m.bash_profile\e[0m:"
|
56
|
+
log " complete -C %s -o default doit" % File.expand_path('../../../extras/completion.rb', __FILE__)
|
55
57
|
end
|
56
58
|
|
57
59
|
desc "show version number"
|
@@ -61,7 +63,7 @@ end
|
|
61
63
|
|
62
64
|
desc "show task list"
|
63
65
|
task :list do
|
64
|
-
formatted = tasks.map { |t| ["\e[1mdoit\e[0m\e[34m %s:%s\e[0m" % [t[:namespace], t[:name]], t[:desc]] }
|
66
|
+
formatted = tasks.map { |t| ["\e[1mdoit\e[0m\e[34m %s:%s \e[0m" % [t[:namespace], t[:name]], t[:desc]] }
|
65
67
|
formatted.each { |f| f[0].gsub!(/\s:/, ' ') }
|
66
68
|
formatted.reject! { |t, desc| desc == '' }
|
67
69
|
max = formatted.max { |a,b| a[0].size <=> b[0].size }[0].size
|
data/lib/do/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: do
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Davide D'Agostino
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-08-
|
18
|
+
date: 2011-08-31 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- Rakefile
|
68
68
|
- bin/doit
|
69
69
|
- do.gemspec
|
70
|
+
- extras/completion.rb
|
70
71
|
- lib/do.rb
|
71
72
|
- lib/do/cli.rb
|
72
73
|
- lib/do/commands.rb
|