mothership 0.0.6 → 0.0.7

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.
@@ -32,7 +32,8 @@ class Mothership
32
32
  name, *argv =
33
33
  Parser.new(@@global).parse_flags(
34
34
  @@inputs.inputs,
35
- argv)
35
+ argv,
36
+ @@commands)
36
37
 
37
38
  app = new
38
39
 
@@ -4,7 +4,7 @@ class Mothership
4
4
  class Command
5
5
  attr_accessor :name, :description
6
6
 
7
- attr_reader :inputs, :arguments, :flags
7
+ attr_reader :context, :inputs, :arguments, :flags
8
8
 
9
9
  attr_reader :before, :after, :around, :filters
10
10
 
@@ -14,14 +14,26 @@ class Mothership
14
14
  inputs
15
15
  end
16
16
 
17
- def parse_flags(inputs, argv)
17
+ def parse_flags(inputs, argv, find_in = nil)
18
+ local = nil
18
19
  args = []
19
20
 
20
21
  until argv.empty?
21
22
  flag = normalize_flag(argv.shift, argv)
22
23
 
23
- name = @command.flags[flag]
24
+ name = local && local.flags[flag] || @command.flags[flag]
24
25
  unless name
26
+ # assume first argument is subcommand
27
+ if args.empty? && find_in && !local
28
+ local = find_in[flag.to_sym]
29
+ end
30
+
31
+ args << flag
32
+ next
33
+ end
34
+
35
+ # skip flags defined by the local cmd
36
+ if local && local.inputs[name]
25
37
  args << flag
26
38
  next
27
39
  end
@@ -1,3 +1,3 @@
1
1
  class Mothership
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mothership
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alex Suraci
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-07-16 00:00:00 Z
18
+ date: 2012-07-19 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rake