Top Level Namespace

Defined Under Namespace

Modules: Git, GitReport, Trollop Classes: GenericSender

Constant Summary collapse

SUB_COMMANDS =
%w(init activate deactivate commit sync import)

Instance Method Summary collapse

Instance Method Details

#dateObject

lib/trollop.rb – trollop command-line processing library

Author

William Morgan (mailto: [email protected])

Copyright

Copyright 2007 William Morgan

License

the same terms as ruby itself



6
# File 'lib/trollop.rb', line 6

require 'date'

#parse_optionsObject



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
59
60
61
62
63
64
65
66
# File 'bin/gitreport', line 14

def parse_options

  global_opts = Trollop::options do
    version "gitreport #{version_info} (c) 2011 gitreport.com team"
    banner <<-EOS
gitreport is a commandline tool to synchronize your git repo's with gitreport.com

Usage: gitreport <subcommand> [options]

<subcommand> must be one of init, activate, deactivate, commit, sync, import

Examples:

gitreport init       - activate automatic data transfer and import existing commit's metadata
gitreport activate   - activate automatic data transfer
gitreport deactivate - unregister your project from gitreport.com
gitreport commit     - manually transfer your last and stored (offline) commit's metadata to gitreport.com
gitreport sync       - manually transfer stored (offline) commit's metadata to gitreport.com
gitreport import     - import existing commits metadata

gitreport allows the folling [options]:
    EOS

    opt :dry_run, "Don't actually do anything", :short => "-n"
    opt :trace, "Print out stack trace in case of an error", :short => "-t"
    stop_on SUB_COMMANDS
  end

  cmd = ARGV.shift
  Trollop::die "You must specify at least one command" unless cmd

  GitReport.global_opts = global_opts

  cmd_opts =
    case cmd
    when "init"
      GitReport::Hook.set!
      GitReport::BatchSender.send! :history
    when "activate"
      GitReport::Hook.set!
    when "deactivate"
      GitReport::Hook.remove!
    when "commit"
      GitReport::Sender.send! :last_and_stored
    when "sync"
      GitReport::Sender.send! :stored
    when "import"
      GitReport::BatchSender.send! :history
    else
      Trollop::die "unknown subcommand #{cmd.inspect}"
    end

end

#version_infoObject



10
11
12
# File 'bin/gitreport', line 10

def version_info
  File.read(File.dirname(__FILE__)+"/../VERSION").strip
end