toolmantim / bananajour

Local git repository hosting with a sexy web interface and bonjour discovery. It's like your own little adhoc, network-aware github!

bananajour / bin / bananajour
100755 58 lines (44 sloc) 1.486 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env ruby
 
require "rubygems"
require (File.symlink?(__FILE__) ? "bananajour" : File.join(File.dirname(__FILE__), "/../lib/bananajour"))
 
Thread.abort_on_exception = true
 
Bananajour.setup! if !Bananajour.setup?
Bananajour.check_git!
Bananajour.check_git_config!
 
case ARGV.first
 
when nil
  Bananajour.serve_web!
  Bananajour.serve_git!
  Bananajour.advertise!
  Process.wait
 
when "add", "init"
  repo = Bananajour.add!(ARGV[1] || File.expand_path("."))
 
when "remove", "rm"
  name = ARGV[1]
 
  if !name || name.empty?
    abort "You need to specify the name of the repository you'd like to remove:\n#{File.basename($0)} remove <path>"
  elsif !(repo = Bananajour::Repository.for_name(name))
    abort "#{name.inspect} is not a valid repository name"
  end
 
  repo.remove!
 
when "clone"
  if ARGV[1].nil? || ARGV[1].empty?
    abort "You need to specify the path to the repository you'd like to clone:\n$ bananajour clone <path>"
  end
  repo = Bananajour.clone!(ARGV[1], ARGV[2])
 
when "help", "--help", "-h"
  puts <<-HELP
Usage: #{File.basename($0)} [<command>]
 
Commands:
none - Start the web, git and bonjour serving
add [path] - Add an existing git repo to bananajour
remove <name> - Remove a repo
clone <url> [path] - Clone a remote repo and add it to bananajour
help
version
HELP
 
when "version", "--version", "-v"
  puts "bananajour version #{Bananajour::VERSION}"
 
else
  abort "Say what? Try: #{File.basename($0)} help"
end