sistero 0.3.0 → 0.4.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
  SHA1:
3
- metadata.gz: adc5b3b7bea1e58657bbf47ddffd5e3efa69c6c1
4
- data.tar.gz: c77fbaf01f32c5833db5960c6cb52b7acc0f92fe
3
+ metadata.gz: 4080a3d41d94a1fc0bf76f4119ee171345ffeac0
4
+ data.tar.gz: 011f83fc73f1089f652443f107f1ecd3e1aee9f7
5
5
  SHA512:
6
- metadata.gz: faec4b54c8ff3d797f16c00d67e6d21598d69ade190ed600205f07823849f0ba104eace69870cc2a2be5de8b5413ac5f89b3132e1cb391c3d0179548e23ab14e
7
- data.tar.gz: 7e0e6901c61589863bbf1a6f23f81e9dbc607b17e04f749ac91a61deccb950ac49722a39d90107b6fd708611b1860d1ce5801db06eb535773eadc4ea88242064
6
+ metadata.gz: b440ed4172f0f1fea35cabb912e3f05f3e6ad6e203f3b5e2ec848e5d2193b8409e1145b7c1ef122ba0242825a32377d3d741f90d0836e8bbf1834235d322863e
7
+ data.tar.gz: 13ef1838719c35eeebfade47f3ae52eaa2289b6fee33d7198c93587d672ee002e50976dba22df501b7e71e663481e7129d6b154b22ee5967d6cf367f632bd6f9
data/README.md CHANGED
@@ -38,7 +38,7 @@ Then to create a VM in new york called default-vm:
38
38
  sistero create
39
39
  ```
40
40
 
41
- Or to create a VM called london-vm in london:
41
+ Or to create a VM called `london-vm` in london:
42
42
  ```
43
- sistero -n london create
43
+ sistero create london
44
44
  ```
data/bin/sistero CHANGED
@@ -2,23 +2,15 @@
2
2
 
3
3
  require 'bundler/setup'
4
4
  require 'sistero'
5
- require 'optparse/subcommand'
6
5
 
7
6
  module Sistero::Command
8
7
  @config = OpenStruct.new
9
- @config.profile_name = 'default'
10
8
 
11
- @subcommands = []
9
+ @subcommands = {}
12
10
  @op = nil
13
11
 
14
- def self.subcommand name, banner
15
- @subcommands.push({ name: name, banner: banner })
16
- @op.subcommand name do |subop|
17
- @config.action = name
18
- subop.banner = banner
19
- with_help subop
20
- yield subop if block_given?
21
- end
12
+ def self.subcommand name, banner, &block
13
+ @subcommands[name] = { name: name, banner: banner, parse_cmdline: block }
22
14
  end
23
15
 
24
16
  def self.with_help help_op
@@ -28,17 +20,35 @@ module Sistero::Command
28
20
  end
29
21
  end
30
22
 
23
+ def self.parse_opts op
24
+ op.order!
25
+
26
+ action = ARGV[0]
27
+ subcmd_meta = @subcommands[action]
28
+ raise "invalid subcommand #{action}" unless @subcommands.has_key? action
29
+ ARGV.shift
30
+
31
+ @config.action = action
32
+ OptionParser.new do |subop|
33
+ subop.banner = subcmd_meta[:banner]
34
+ with_help subop
35
+ parse_cmdline = subcmd_meta[:parse_cmdline]
36
+ parse_cmdline.call(subop) if parse_cmdline
37
+ end.order!
38
+ @config.action_arg = ARGV[0]
39
+ end
40
+
31
41
  def self.run
32
42
  OptionParser.new do |op|
33
43
  @op = op
34
44
 
35
45
  op.banner = 'usage: sistero [global options] command [command options]'
36
46
  op.on '-h', '--help', 'show this help message' do
37
- max_len = @subcommands.map { |subcommand| subcommand[:name].length }.max
47
+ max_len = @subcommands.values.map { |subcommand| subcommand[:name].length }.max
38
48
 
39
49
  puts op
40
50
  puts "\ncommands:"
41
- @subcommands.each do |subcommand|
51
+ @subcommands.values.each do |subcommand|
42
52
  prefix = subcommand[:name]
43
53
  prefix += ' ' * (max_len - prefix.length + 2)
44
54
  puts " #{prefix} #{subcommand[:banner]}"
@@ -46,10 +56,6 @@ module Sistero::Command
46
56
  exit
47
57
  end
48
58
 
49
- op.on '-n vm-name', '--name', 'set vm name' do |vm_name|
50
- @config.vm_name = vm_name
51
- end
52
-
53
59
  subcommand 'ssh', 'ssh to vm' do |subop|
54
60
  subop.on '-o val', 'add ssh options' do |ssh_options|
55
61
  @config.ssh_options = ssh_options
@@ -64,7 +70,7 @@ module Sistero::Command
64
70
 
65
71
  subcommand 'show-config', 'show configuration'
66
72
 
67
- op.parse!
73
+ parse_opts op
68
74
  end
69
75
 
70
76
  unless @config.action
@@ -72,7 +78,7 @@ module Sistero::Command
72
78
  exit
73
79
  end
74
80
 
75
- vm_name = @config.vm_name
81
+ vm_name = @config.action_arg
76
82
 
77
83
  begin
78
84
  sistero = Sistero::Instance.new
@@ -1,3 +1,3 @@
1
1
  module Sistero
2
- VERSION = "0.3.0"
2
+ VERSION = '0.4.0'
3
3
  end
data/sistero.gemspec CHANGED
@@ -31,5 +31,4 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency "rspec"
32
32
 
33
33
  spec.add_development_dependency "droplet_kit", "~> 1.3"
34
- spec.add_development_dependency "optparse-subcommand"
35
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sistero
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Pike
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.3'
69
- - !ruby/object:Gem::Dependency
70
- name: optparse-subcommand
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
69
  description: Profile based digital ocean cluster management command line tool.
84
70
  email:
85
71
  - github@chilon.net