git_switch 0.4.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/git_switch/config.rb +4 -0
- data/lib/git_switch/options.rb +12 -2
- data/lib/git_switch/switcher.rb +8 -3
- data/lib/git_switch/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8666669a31d473dd95b1e146ba0f93dd632eb50e9978ccf98dba586aca2024f0
|
4
|
+
data.tar.gz: 06d995d4e3ae428fde0859386705e3e4076616471f3f9a895071380353e82b14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5869a28a72a167fd4f8875d2e2caa9cd7fca5b6f87e082192bf53d03e4824020f74e40a98ad5ec84f43ac143ff89989c8d04c69ee3b292e788c3c4891f37d17c
|
7
|
+
data.tar.gz: 78643a8eab498b6d766482c389d66840bdce04316a90c29bd6868fd6bfd85b29e96ae3f691628a854d8783d25bca67fd024f9610d89a9bece21048cfad1491f9
|
data/lib/git_switch/config.rb
CHANGED
@@ -51,6 +51,10 @@ module GitSwitch
|
|
51
51
|
write_profiles_to_config_file if @profiles.any?
|
52
52
|
end
|
53
53
|
|
54
|
+
def edit!
|
55
|
+
system("#{ENV['EDITOR']} '#{File.expand_path('~/.gitswitch')}'")
|
56
|
+
end
|
57
|
+
|
54
58
|
def build_profiles
|
55
59
|
puts "How many profiles would you like to create?"
|
56
60
|
profile_count = STDIN.gets.chomp.to_i
|
data/lib/git_switch/options.rb
CHANGED
@@ -7,14 +7,16 @@ module GitSwitch
|
|
7
7
|
|
8
8
|
def flags
|
9
9
|
@flags ||= args.select do |arg|
|
10
|
-
arg.match(/\A\-[
|
11
|
-
arg.match(/\A\-\-(config|global|list|verbose|version){1}\z/)
|
10
|
+
arg.match(/\A\-[ceglv]{1}\z/) ||
|
11
|
+
arg.match(/\A\-\-(config|edit|global|list|verbose|version){1}\z/)
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
def valid_args?
|
16
16
|
if config?
|
17
17
|
return true
|
18
|
+
elsif edit?
|
19
|
+
return true
|
18
20
|
elsif list?
|
19
21
|
return true
|
20
22
|
elsif version?
|
@@ -41,6 +43,10 @@ module GitSwitch
|
|
41
43
|
config_flag? && args.count == 1
|
42
44
|
end
|
43
45
|
|
46
|
+
def edit?
|
47
|
+
edit_flag? && args.count == 1
|
48
|
+
end
|
49
|
+
|
44
50
|
def list?
|
45
51
|
list_flag? && args.count == 1
|
46
52
|
end
|
@@ -63,6 +69,10 @@ module GitSwitch
|
|
63
69
|
(flags.include? '-c') || (flags.include? '--config')
|
64
70
|
end
|
65
71
|
|
72
|
+
def edit_flag?
|
73
|
+
(flags.include? '-e') || (flags.include? '--edit')
|
74
|
+
end
|
75
|
+
|
66
76
|
def list_flag?
|
67
77
|
(flags.include? '-l') || (flags.include? '--list')
|
68
78
|
end
|
data/lib/git_switch/switcher.rb
CHANGED
@@ -4,8 +4,8 @@ require 'active_support/core_ext/module/delegation'
|
|
4
4
|
module GitSwitch
|
5
5
|
class Switcher
|
6
6
|
attr_reader :config, :options
|
7
|
-
delegate :usage?, :config?, :list?, :version?, :global?, to: :options
|
8
|
-
delegate :profile, :name, :username, :email, :ssh, :ssh_command, :print_list, :configure!, :valid_profile?, to: :config
|
7
|
+
delegate :usage?, :config?, :edit?, :list?, :version?, :global?, to: :options
|
8
|
+
delegate :profile, :name, :username, :email, :ssh, :ssh_command, :print_list, :configure!, :edit!, :valid_profile?, to: :config
|
9
9
|
|
10
10
|
def initialize(args)
|
11
11
|
raise ArgumentError unless args.is_a? Array
|
@@ -19,6 +19,8 @@ module GitSwitch
|
|
19
19
|
print_usage
|
20
20
|
elsif config?
|
21
21
|
configure!
|
22
|
+
elsif edit?
|
23
|
+
edit!
|
22
24
|
elsif list?
|
23
25
|
print_list
|
24
26
|
elsif version?
|
@@ -87,12 +89,15 @@ module GitSwitch
|
|
87
89
|
|
88
90
|
def usage
|
89
91
|
<<~USAGE
|
90
|
-
usage: git switch [-c | --config] [-l | --list] [-v | --version]
|
92
|
+
usage: git switch [-c | --config] [-e | --edit] [-l | --list] [-v | --version]
|
91
93
|
<profile> [-v | --verbose] [-g | --global]
|
92
94
|
|
93
95
|
configure profiles
|
94
96
|
git switch -c
|
95
97
|
|
98
|
+
open configuration file in editor
|
99
|
+
git switch -e
|
100
|
+
|
96
101
|
switch to a profile for local development only
|
97
102
|
git switch <profile>
|
98
103
|
|
data/lib/git_switch/version.rb
CHANGED