entangler 0.1.2 → 0.2.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: e910a8be4617a7df89c5a0d5f94b51617a26deb6
4
- data.tar.gz: 1d083cf56c15e7f332c703eb36381d31e717b7f6
3
+ metadata.gz: 4338665fa9a10ccedafc5eca1b0ad709fd351f01
4
+ data.tar.gz: 06eeb20f8ed99e4c74a4a3a930a95e3a306f84ca
5
5
  SHA512:
6
- metadata.gz: 829fd8b9cc788a049e1daab942a3eff9d911351f580b71f276610c0c48b758638698868066ceb39e3bac63a6bebc7e295915d19fd95d7f93e4a66a0bfe057b65
7
- data.tar.gz: b08f880f5e249658f83b906e3789adf84b999d9922b068dc6eec037aa069475a62434212287f3a3898f56661a1a01c43911eab4c9b70fd6c59a12f153edd92ef
6
+ metadata.gz: 142266121a2a95f0f4936f008d3906bdcc10ca8eb56c32d8106d2deafbe43234d72d61054c846f5438a451c6e0b845505cafba0bd51527c191f9fadb8bfd7321
7
+ data.tar.gz: d44890b934d08df1bfe4f49b9d769019ca4849e43410dcc7488f7e887164bc3db6606fe2f109e9f5f2f5feca26847c4c77eca1f02d9e8a1b4bde8fba0ae377d0
data/exe/entangler CHANGED
@@ -1,21 +1,65 @@
1
1
  #!/usr/bin/env ruby
2
- require "entangler"
2
+ require 'entangler'
3
+ require 'optparse'
3
4
 
4
- mode = ARGV[0]
5
- opts = {}
5
+ options = {}
6
+ OptionParser.new do |opts|
7
+ opts.banner = "Usage:\n entangler master <base_dir> <remote_user>@<remote_host>:<remote_base_dir> [options]\n entangler slave <base_dir> [options]"
6
8
 
7
- raise 'Must supply at least 2 args' unless ARGV.length >= 2
9
+ opts.separator ""
10
+ opts.separator "Options:"
11
+
12
+ opts.on("-p", "--port PORT", "Overwrite the SSH port (usually 22)", "(doesn't do anything in slave mode)") do |port|
13
+ options[:port] = port
14
+ end
15
+
16
+ opts.on_tail("-v", "--version", "Show version number") do |v|
17
+ puts Entangler::VERSION
18
+ exit
19
+ end
20
+
21
+ opts.on_tail("-h", "--help", "Show this message") do
22
+ puts opts
23
+ exit
24
+ end
25
+ end.parse!
26
+
27
+ mode = ARGV.shift
28
+ unless mode && ['master', 'slave'].include?(mode)
29
+ puts "Mode unknown, please read help:\nentangler -h"
30
+ exit 1
31
+ end
32
+
33
+ base_dir = ARGV.shift
34
+ unless base_dir
35
+ puts "Missing base directory"
36
+ exit 1
37
+ end
8
38
 
9
39
  if mode == 'master'
10
- raise 'Missing remote argument' unless ARGV.length >= 3
11
- user, rest = ARGV[2].split('@', 2)
12
- host, path = rest.split(':', 2)
40
+ remote_information = ARGV.shift
41
+
42
+ unless remote_information
43
+ raise 'Missing remote information'
44
+ exit 1
45
+ end
46
+
47
+ user, rest = remote_information.split('@', 2)
48
+ host, path = (rest || '').split(':', 2)
49
+
50
+ error = nil
51
+ error = 'Missing remote user' unless user
52
+ error = 'Missing remote host' unless host
53
+ error = 'Missing remote path' unless path
54
+ unless error.nil?
55
+ puts error
56
+ exit 1
57
+ end
58
+
13
59
  opts = {remote_base_dir: path, remote_user: user, remote_host: host}
14
- opts[:remote_port] = ARGV[3] if ARGV[3]
15
- elsif mode == 'slave'
16
- opts[:mode] = 'slave'
60
+ opts[:remote_port] = options[:port] if options[:port]
17
61
  else
18
- raise "Mode: #{mode} unknown, please read documentation"
62
+ opts = {mode: 'slave'}
19
63
  end
20
64
 
21
- Entangler.run(ARGV[1], opts)
65
+ Entangler.run(base_dir, opts)
@@ -1,3 +1,3 @@
1
1
  module Entangler
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: entangler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Allie