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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88c9368e5196597ef5c0101730f0f97cafbc4591c5ccdca441b0755a3d5ce9c0
4
- data.tar.gz: 981733456ef6f72ed7170272c8f69a4fa0756d81d4e7b39a7c00e0eabcd332f7
3
+ metadata.gz: 8666669a31d473dd95b1e146ba0f93dd632eb50e9978ccf98dba586aca2024f0
4
+ data.tar.gz: 06d995d4e3ae428fde0859386705e3e4076616471f3f9a895071380353e82b14
5
5
  SHA512:
6
- metadata.gz: f040bf16f1ddf8331c4d3f4f6f55a4b07dbaa1ebff5794338636b9196b01bc1917b9aa8b5392ca498e359938bab4dd41701a175fa86f2a12a0a5e9d9c2254ee0
7
- data.tar.gz: 3ff85061b060d5ca21a2592cb78af0a1b1ce1f17f6ec0b307fd2ec4ce410839033b0fceef4843480012ad8b7ad37bb678ec8e05bf244fc375823123f67244326
6
+ metadata.gz: 5869a28a72a167fd4f8875d2e2caa9cd7fca5b6f87e082192bf53d03e4824020f74e40a98ad5ec84f43ac143ff89989c8d04c69ee3b292e788c3c4891f37d17c
7
+ data.tar.gz: 78643a8eab498b6d766482c389d66840bdce04316a90c29bd6868fd6bfd85b29e96ae3f691628a854d8783d25bca67fd024f9610d89a9bece21048cfad1491f9
@@ -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
@@ -7,14 +7,16 @@ module GitSwitch
7
7
 
8
8
  def flags
9
9
  @flags ||= args.select do |arg|
10
- arg.match(/\A\-[cglv]{1}\z/) ||
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
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module GitSwitch
2
- VERSION = "0.4.3"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_switch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Randall Reed, Jr.