changit 0.2.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 372f010fb7fc1efe5ddaaba7a9ff3a7f7e498d0d
4
- data.tar.gz: ec1d0128d5a9918ad1edb7605bcce4c523582c13
3
+ metadata.gz: 076d3ca051c1b061e2e66ed520eb75a205b76a61
4
+ data.tar.gz: 87ccbdfcacf49c8c95774a46879444673395f3f6
5
5
  SHA512:
6
- metadata.gz: 19fe3ed541cc2c97c30f59593d256aad6b5d665d5ea961d9039c1f30df7c3a6180ef5a7a2bc853c7145051fec50813c2e8a80980be7acd855ee84ec3472a5aa3
7
- data.tar.gz: af5b46096c6b14c07bdf661799687887327702e3678e6fe7b86a1b1bd86d94b9250687ec232e6c36a79439b737a059d8ea4a7051eff1bbd3bdb755e32be264c8
6
+ metadata.gz: a970bd68cba72a8d36261f86148aa1519daf53f5753380e74758b8d3c8f657e108dca0169a2bf94dd5bbede8d518c1b7339c18a6cd50fa162a05202f0ae53a88
7
+ data.tar.gz: 6942d0f4a470de75778a5dfda520ab5a20b6d9198a85fcb8218375c33e621ab080332d7f5db63a4173b32dabfc348caded4b924d8d3455889293f72f5954e93d
data/README.md CHANGED
@@ -18,6 +18,13 @@ file with your configuration, and run:
18
18
  changit
19
19
  ```
20
20
 
21
+ ### CLI
22
+ To see the CLI options, type:
23
+
24
+ ```sh
25
+ changit -h
26
+ ```
27
+
21
28
  ## Demo
22
29
 
23
30
  ![changit GIF demo](/demo.gif)
data/bin/changit CHANGED
@@ -2,4 +2,5 @@
2
2
 
3
3
  require 'changit'
4
4
 
5
- Changit.run
5
+ options = Changit::CLI.new
6
+ Changit.run(options[:src_path], options[:target_paths])
@@ -0,0 +1,42 @@
1
+ require 'optparse'
2
+
3
+ module Changit
4
+ class CLI
5
+ def initialize
6
+ options = {}
7
+ options[:target_paths] = []
8
+
9
+ opt_parser = OptionParser.new do |opt|
10
+ opt.banner = "Usage: changit [OPTIONS]"
11
+ opt.separator ""
12
+ opt.separator "Options"
13
+
14
+ opt.on("-s","--source SOURCE","Which gitconfig file to copy from") do |src_path|
15
+ options[:src_path] = src_path
16
+ end
17
+
18
+ opt.on("-t","--target TARGET","Which directory to copy the config to."\
19
+ " To copy to different directories, pass more than one -t argument each for one directory"
20
+ ) do |target_path|
21
+ options[:target_paths] << target_path
22
+ end
23
+
24
+ opt.on("-v","--version","Show version number") do
25
+ puts Changit::VERSION
26
+ exit
27
+ end
28
+
29
+ opt.on("-h","--help","Show CLI options") do
30
+ puts opt_parser
31
+ exit
32
+ end
33
+ end
34
+
35
+ opt_parser.parse!
36
+
37
+ options[:target_paths] = nil if options[:target_paths].empty?
38
+ options
39
+ end
40
+ end
41
+ end
42
+
@@ -4,7 +4,8 @@ module Changit
4
4
 
5
5
  attr_reader :search_path
6
6
 
7
- def initialize(search_path: DEFAULT_SEARCH_PATH)
7
+ def initialize(search_path: nil)
8
+ search_path ||= DEFAULT_SEARCH_PATH
8
9
  @search_path = search_path
9
10
 
10
11
  freeze
@@ -2,14 +2,15 @@ module Changit
2
2
  class GitDirFinder
3
3
  DEFAULT_SEARCH_PATH = Dir.pwd.freeze
4
4
 
5
- def initialize(search_path: DEFAULT_SEARCH_PATH)
6
- @search_path = "#{search_path}/**/.git/config"
5
+ def initialize(search_paths: nil)
6
+ search_paths ||= [DEFAULT_SEARCH_PATH]
7
+ @search_paths = search_paths.collect! { |path| "#{path}/**/.git/config" }
7
8
 
8
9
  freeze
9
10
  end
10
11
 
11
12
  def find_all
12
- Dir.glob(@search_path)
13
+ Dir.glob(@search_paths)
13
14
  end
14
15
  end
15
16
  end
@@ -1,3 +1,3 @@
1
1
  module Changit
2
- VERSION='0.2.2'
2
+ VERSION='1.0.0'
3
3
  end
data/lib/changit.rb CHANGED
@@ -6,14 +6,15 @@ require 'changit/git_dir_finder'
6
6
  require 'changit/config_merger'
7
7
  require 'changit/config_reader'
8
8
  require 'changit/config_writer'
9
+ require 'changit/cli'
9
10
 
10
11
  module Changit
11
- def self.run
12
+ def self.run(src_file, target_files)
12
13
  # File to copy from
13
- config = ConfigReader.new.read
14
+ config = ConfigReader.new(search_path: src_file).read
14
15
 
15
16
  # First, search directories inside the current pwd and make sure they contain a .git dir
16
- files_to_write_to = GitDirFinder.new.find_all
17
+ files_to_write_to = GitDirFinder.new(search_paths: target_files).find_all
17
18
 
18
19
  # Then, copy the gitconfig file content to each .git/config file in these directories
19
20
  ConfigWriter.new(config, files_to_write_to).write
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: changit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - aaooki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-03 00:00:00.000000000 Z
11
+ date: 2016-12-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: An over-engineered tool to change git config for multiple projects at
14
14
  once.
@@ -27,6 +27,7 @@ files:
27
27
  - changit.gemspec
28
28
  - demo.gif
29
29
  - lib/changit.rb
30
+ - lib/changit/cli.rb
30
31
  - lib/changit/config_merger.rb
31
32
  - lib/changit/config_reader.rb
32
33
  - lib/changit/config_writer.rb