rcli 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/commands/version.rb +3 -3
- data/lib/config/application.yml +8 -0
- data/lib/rcli.rb +1 -1
- metadata +4 -5
- data/README.md +0 -193
data/Rakefile
CHANGED
@@ -19,7 +19,7 @@ begin
|
|
19
19
|
gem.executables = ['rcli']
|
20
20
|
gem.require_paths = ['lib']
|
21
21
|
|
22
|
-
gem.files = FileList['lib/**/*.rb','README*', 'LICENSE', 'Rakefile', 'test/**/*.*', 'bin/**/*.rb'].to_a
|
22
|
+
gem.files = FileList['lib/config/*','lib/**/*.rb','README*', 'LICENSE', 'Rakefile', 'test/**/*.*', 'bin/**/*.rb'].to_a
|
23
23
|
end
|
24
24
|
Jeweler::GemcutterTasks.new
|
25
25
|
rescue LoadError
|
data/lib/commands/version.rb
CHANGED
@@ -3,9 +3,9 @@ class VersionCommand < Command
|
|
3
3
|
description "Shows the current version of the application."
|
4
4
|
|
5
5
|
def main
|
6
|
-
options = parse
|
6
|
+
#options = parse
|
7
7
|
|
8
|
-
puts "#{Rcli.script_config['global']['script_name']} version 0.
|
8
|
+
puts "#{Rcli.script_config['global']['script_name']} version 0.1.1"
|
9
9
|
end
|
10
10
|
|
11
|
-
end
|
11
|
+
end
|
data/lib/rcli.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Eduardo Del Balso
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-11-09 00:00:00 -05:00
|
18
18
|
default_executable: rcli
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -55,11 +55,9 @@ extensions: []
|
|
55
55
|
|
56
56
|
extra_rdoc_files:
|
57
57
|
- LICENSE
|
58
|
-
- README.md
|
59
58
|
- README.rdoc
|
60
59
|
files:
|
61
60
|
- LICENSE
|
62
|
-
- README.md
|
63
61
|
- README.rdoc
|
64
62
|
- Rakefile
|
65
63
|
- lib/commands/compile.rb
|
@@ -71,6 +69,7 @@ files:
|
|
71
69
|
- lib/commands/list.rb
|
72
70
|
- lib/commands/uninstall.rb
|
73
71
|
- lib/commands/version.rb
|
72
|
+
- lib/config/application.yml
|
74
73
|
- lib/core/actions.rb
|
75
74
|
- lib/core/actions/create_file.rb
|
76
75
|
- lib/core/actions/empty_directory.rb
|
data/README.md
DELETED
@@ -1,193 +0,0 @@
|
|
1
|
-
# rcli
|
2
|
-
|
3
|
-
## WHAT IS THIS
|
4
|
-
|
5
|
-
rcli is a simple tool for writing and managing command-line applications. It
|
6
|
-
spawned simply from me not liking the idea that I have to type 'thor' before
|
7
|
-
my command line scripts. This is my take on getting this done a little more
|
8
|
-
cleanly.
|
9
|
-
|
10
|
-
## CAVEAT
|
11
|
-
|
12
|
-
This was done a project to learn ruby, and is by no means perfect. If you like
|
13
|
-
it, please let me know. If you would like to add features, also let me
|
14
|
-
know as I'll be glad to hear your ideas and integrate your code.
|
15
|
-
|
16
|
-
Most importantly, if you have ideas of things I did wrong and could do better,
|
17
|
-
let me know! The point is for me to learn, hopefully you find use in this at
|
18
|
-
the same time.
|
19
|
-
|
20
|
-
## INSTALLATION
|
21
|
-
|
22
|
-
Find a nice place to put this repo. I like:
|
23
|
-
|
24
|
-
mkdir -p ~/lib/ruby
|
25
|
-
cd ~/lib/ruby
|
26
|
-
git clone git://github.com/edelbalso/rcli.git
|
27
|
-
|
28
|
-
Now build the gem
|
29
|
-
|
30
|
-
cd rcli
|
31
|
-
build rcli.gemspec
|
32
|
-
gem install rcli-0.6.gem
|
33
|
-
|
34
|
-
Then install the required gems:
|
35
|
-
|
36
|
-
gem install highline
|
37
|
-
gem install text
|
38
|
-
|
39
|
-
and you should be good to go. Try:
|
40
|
-
|
41
|
-
rcli
|
42
|
-
|
43
|
-
If you don't get a page full of exceptions, you're good to go. If so,
|
44
|
-
get in touch with me and I will help you out.
|
45
|
-
|
46
|
-
## ADVANCED INSTALLATION
|
47
|
-
|
48
|
-
*WARNING! WARNING!*
|
49
|
-
|
50
|
-
I suggest you back up your ~/.bash_profile before completing this
|
51
|
-
step. You've been warned.
|
52
|
-
|
53
|
-
*END WARNING!*
|
54
|
-
|
55
|
-
rcli has the capability of 'installing' the applications you make with
|
56
|
-
it so that they're available system-wide. It does this by creating a
|
57
|
-
'.rcli' hidden folder and storing the locations of your applications
|
58
|
-
once they're installed.
|
59
|
-
|
60
|
-
To set up this folder in your home directory, type:
|
61
|
-
|
62
|
-
rcli install
|
63
|
-
|
64
|
-
It will then prompt you to add a line to your .bash_profile. If you've
|
65
|
-
succesfully backed up your .bash_profile, go ahead and accept this. The
|
66
|
-
uninstall doesn't yet remove the added lines, so if you've done this once,
|
67
|
-
no point in doing it again or it will just mess up your file unecessarily.
|
68
|
-
|
69
|
-
Once installed, do this to load the path into your terminal:
|
70
|
-
|
71
|
-
source ~/.bash_profile
|
72
|
-
|
73
|
-
## WRITING YOUR FIRST APP
|
74
|
-
|
75
|
-
To get started with rcli, simply create a folder anywhere in your home
|
76
|
-
folder where you'd like to keep your applications. I like:
|
77
|
-
|
78
|
-
mkdir -p ~/lib/ruby/rcli_apps/
|
79
|
-
|
80
|
-
but any folder will do. Now create your app:
|
81
|
-
|
82
|
-
cd ~/lib/ruby/rcli_apps/
|
83
|
-
rcli generate gemate
|
84
|
-
rcli install gemate/gemate.rb gemate
|
85
|
-
|
86
|
-
You should now have created an application 'gemate' that can be used
|
87
|
-
from anywhere on your system. Go ahead and confirm this:
|
88
|
-
|
89
|
-
rcli list
|
90
|
-
|
91
|
-
'gemate' should be listed here. If you have textmate installed, you
|
92
|
-
can now go ahead and edit the generate app by typing:
|
93
|
-
|
94
|
-
rcli edit gemate
|
95
|
-
|
96
|
-
and you can go ahead and rename the command located at 'lib/commands/example.rb'
|
97
|
-
to 'lib/commands/view.rb'
|
98
|
-
|
99
|
-
mv gemate/lib/commands/example.rb gemate/lib/commands/view.rb
|
100
|
-
|
101
|
-
and put the following code in the file:
|
102
|
-
|
103
|
-
class ViewCommand < Command
|
104
|
-
|
105
|
-
def after_init
|
106
|
-
# called after Command::initialize
|
107
|
-
@description = "Opens a gem (or gems) to be viewed in Textmate"
|
108
|
-
end
|
109
|
-
|
110
|
-
def main
|
111
|
-
|
112
|
-
if @params[:args].size != 1
|
113
|
-
puts "ERROR: please provide a gem name to look up"
|
114
|
-
end
|
115
|
-
|
116
|
-
name = @params[:args][0]
|
117
|
-
term = name + '*'
|
118
|
-
|
119
|
-
puts "Searching for '" + term + "'..."
|
120
|
-
|
121
|
-
# get the path to the gem directory from rubygems and search for any matching directories
|
122
|
-
path = `gem env gemdir`
|
123
|
-
new_path = File.join([path.chomp, 'gems'])
|
124
|
-
Dir.chdir(new_path)
|
125
|
-
@d_arr = Dir.glob(term)
|
126
|
-
|
127
|
-
if @d_arr.empty?
|
128
|
-
puts "Sorry, nothing like that found"
|
129
|
-
elsif @d_arr.size == 1
|
130
|
-
view_one()
|
131
|
-
else
|
132
|
-
view_list()
|
133
|
-
end
|
134
|
-
|
135
|
-
end
|
136
|
-
|
137
|
-
private
|
138
|
-
|
139
|
-
def view_one
|
140
|
-
puts @d_arr.first
|
141
|
-
print 'Do you want to view this? [Y/n]: '
|
142
|
-
resp = $stdin.gets.chomp!
|
143
|
-
if resp.empty? or resp.downcase == 'y'
|
144
|
-
exec "mate #{@d_arr.first}"
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
def view_list
|
149
|
-
@d_arr.each_with_index {|d,i| puts "#{i + 1}: #{d}"}
|
150
|
-
puts
|
151
|
-
print 'Choose a directory or quit(q): '
|
152
|
-
idx = gets.chomp!
|
153
|
-
if idx.downcase == 'q'
|
154
|
-
exit
|
155
|
-
elsif (1..@d_arr.size).include?(idx.to_i)
|
156
|
-
exec "mate #{@d_arr.at(idx.to_i - 1)}"
|
157
|
-
else
|
158
|
-
puts 'not a valid option'
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
end
|
163
|
-
|
164
|
-
This code has been ripped off from one of the Thor tutorials. My apologies.
|
165
|
-
|
166
|
-
Anyways, after saving this file, you should now be able to type
|
167
|
-
|
168
|
-
gemate view thor
|
169
|
-
|
170
|
-
and textmate should pop up with the thor. You should similarly be able to
|
171
|
-
view any other gem installed on your system.
|
172
|
-
|
173
|
-
Congrats, you've made your first command-line app with rcli.
|
174
|
-
|
175
|
-
## TO DO
|
176
|
-
|
177
|
-
* Trollop is being used to parse commands. I need to clean up command-level
|
178
|
-
customization of trollop
|
179
|
-
* Wrap shell commands provided by highline into something clean.
|
180
|
-
|
181
|
-
## DEPENDENCIES
|
182
|
-
|
183
|
-
sudo gem install highline
|
184
|
-
sudo gem install text
|
185
|
-
|
186
|
-
|
187
|
-
## ACKNOWLEDGEMENTS
|
188
|
-
|
189
|
-
* Yehuda Katz for code I copied from Thor::Actions modules, as well as a bunch of other chunks. :)
|
190
|
-
|
191
|
-
## AUTHOR
|
192
|
-
|
193
|
-
Eduardo Del Balso
|