Class: GitSwitch::Switcher
- Inherits:
-
Object
- Object
- GitSwitch::Switcher
- Defined in:
- lib/git_switch/switcher.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #git_repo? ⇒ Boolean
-
#initialize(args) ⇒ Switcher
constructor
A new instance of Switcher.
- #print_settings ⇒ Object
- #print_usage ⇒ Object
- #print_version ⇒ Object
- #run ⇒ Object
- #set! ⇒ Object
Constructor Details
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/git_switch/switcher.rb', line 6 def config @config end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/git_switch/switcher.rb', line 6 def @options end |
Instance Method Details
#git_repo? ⇒ Boolean
33 34 35 36 37 38 39 40 |
# File 'lib/git_switch/switcher.rb', line 33 def git_repo? if GitHelper.git_repo? || global? return true else puts "Not a git repo. Please run from a git repo or run with `-g` to update global settings." return false end end |
#print_settings ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/git_switch/switcher.rb', line 58 def print_settings if .verbose? puts "\nGit Config:" puts `git config #{git_config_flag} -l --show-origin | grep user` puts "\nSSH:" puts `ssh-add -l` else puts "Switched to profile #{profile}" end end |
#print_usage ⇒ Object
50 51 52 |
# File 'lib/git_switch/switcher.rb', line 50 def print_usage puts usage end |
#print_version ⇒ Object
54 55 56 |
# File 'lib/git_switch/switcher.rb', line 54 def print_version puts GitSwitch::VERSION end |
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/git_switch/switcher.rb', line 16 def run return unless .valid_args? if usage? print_usage elsif config? configure! elsif edit? edit! elsif list? print_list elsif version? print_version else set! end end |
#set! ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/git_switch/switcher.rb', line 42 def set! return unless valid_profile? && git_repo? set_git_config set_ssh print_settings end |