Class: Eo
- Inherits:
-
Object
- Object
- Eo
- Defined in:
- lib/eo.rb,
lib/eo/eo.rb
Constant Summary collapse
- Repos =
Hash.new
- Config_file =
File.join("#{ENV['HOME']}",".eorc")
Class Method Summary collapse
- .choose(*args) ⇒ Object
- .execute(args) ⇒ Object
- .help ⇒ Object
- .init(*args) ⇒ Object
- .run ⇒ Object
- .show(*args) ⇒ Object
- .type ⇒ Object
- .update(*args) ⇒ Object
Class Method Details
.choose(*args) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/eo/eo.rb', line 70 def choose(*args) repos = pick(args) if repos && repos = repos.to_s # Convert Array To String return false unless exist_path(repos) loop do printf("\e[01;34m#{repos} (h:help)>> \e[0m") input = STDIN.gets.strip break if input =~ /\A\s*q\s*\Z/ exit if input =~ /\A\s*Q\s*\Z/ Repos[repos].send(input) unless input.empty? end end end |
.execute(args) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/eo.rb', line 5 def self.execute(args) case args.first when "-s" then self.show(args[1,args.size]) when "-c" then self.choose(args[1,args.size]) when "-i" then self.init(args[1,args.size]) when "-u" then self.update(args[1,args.size]) when "-t" then self.type when "-v" then puts "\e[33mEo_oE : v" + Easyoperate::VERSION + "\e[0m" when "-h" then puts <<-DOC.gsub(/^(\s*\|)/,'') |Usage: #{File.basename($0)} [options] [ARGS] |Options are: | -u Update Repository. <Regexp> | -s Show All Repositories. <Regexp> | -v Show version information. | -c Choose Repository. | -t Show All Support Scm | -i Initialize Repository. <Regexp> DOC else self.run end end |
.help ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/eo/eo.rb', line 37 def help puts <<-DOC.gsub(/^(\s*\|)/,'') |Usage: | S /args/ : Show matched repositories <Regexp> | C /args/ : Choose One Repository <Regexp> | U /args/ : Update matched Repository <Regexp> | I /args/ : Initialize matched Repository <Regexp> | T : Show All Support Scm | Q : Quit | H : Show this help message. |e.g:\n \e[32m s v.*m\e[0m DOC end |
.init(*args) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/eo/eo.rb', line 85 def init(*args) repos = pick(args,false) repos.each do |x| if File.exist?(Repos[x].path) puts "\e[32m %-18s: already Initialized\e[0m" % [x] next end puts "\e[32m %-18s: Initializing\e[0m" % [x] Repos[x].init end end |
.run ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/eo/eo.rb', line 19 def run loop do printf("\e[33mInput Commands (q:quit h:help): \e[0m") input = STDIN.gets.split(' ',2) input[1] ? input[1].strip! : next case input[0].to_s when /S/i then show(input[1]) when /C/i then choose(input[1]) when /U/i then update(input[1]) when /I/i then init(input[1]) when /T/i then type when /Q/i then exit else help end end end |
.show(*args) ⇒ Object
64 65 66 67 68 |
# File 'lib/eo/eo.rb', line 64 def show(*args) repos = pick(args,false) puts "\e[33mAll Repo match < #{args} > :\e[0m" format_display(repos) end |
.type ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/eo/eo.rb', line 51 def type ["#{ENV['HOME']}/.eo/scm/",File.join(File.dirname(__FILE__),'scm')].each do |x| next if !File.exist?(x) (@scm ||= []).concat(Dir.new(x).entries.reject {|i| i =~/^\.+$/}) end puts "\e[33mAll Scm-type :\e[0m" @scm.uniq.map do |x| (@formated_scm ||= []) << File.basename(x,".rb") end format_display(@formated_scm) end |