Class: GitSu::Gitsu

Inherits:
Object
  • Object
show all
Defined in:
lib/gitsu/gitsu.rb

Instance Method Summary collapse

Constructor Details

#initialize(switcher, output) ⇒ Gitsu

Returns a new instance of Gitsu.



22
23
24
# File 'lib/gitsu/gitsu.rb', line 22

def initialize(switcher, output)
    @switcher, @output = switcher, output
end

Instance Method Details

#go(args) ⇒ Object



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
67
68
69
70
71
72
73
74
75
76
# File 'lib/gitsu/gitsu.rb', line 26

def go(args)
    options = {}
    optparse = OptionParser.new do |opts|
        opts.version = GitSu::VERSION
        opts.banner = <<-BANNER
Gitsu Copyright (C) 2013  drrb
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under
certain conditions; see <http://www.gnu.org/licenses/> for details.

Usage: git-su [options] user
        BANNER

        opts.on('-t', '--list', 'List the configured users') do
            options[:list] = true
        end

        opts.on('-c', '--clear', 'Clear the current user') do
            options[:clear] = true
        end

        opts.on('-a', '--add USER', 'Add a user in email format (e.g. John Citizen <[email protected]>)') do |user|
            options[:add] = user
        end

        opts.on('-e', '--edit', 'Open the Gitsu config file in an editor') do
            options[:edit] = true
        end

        options[:scope] = []
        opts.on('-l', '--local', 'Change user in local scope') do
            options[:scope] << :local
        end

        opts.on('-g', '--global', 'Change user in global scope') do
            options[:scope] << :global
        end

        opts.on('-s', '--system', 'Change user in system scope') do
            options[:scope] << :system
        end

        opts.on('-h', '--help', 'Show this message') do
            options[:help] = true
            @output.puts opts
        end
    end

    optparse.parse! args
    run(options, args)
end