belafonte 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/belafonte/help/app_extensions.rb +32 -10
- data/lib/belafonte/help/generator.rb +9 -1
- data/lib/belafonte/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f5509c92ec5d0ddd52432d56f34702b797d9240
|
4
|
+
data.tar.gz: 2b6399b51a131dda9ad8b6458da6581c4e556c01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 598b0bd646258d587cc43a5a8d70bcb67d55795b23243080138bf3ebe1a4a7fcfbcd190659421185e43497609eb6678c99a1136a64e413ab6c8a6808c8d20c3c
|
7
|
+
data.tar.gz: 1c7c03b1c6da23bd3bb44a3dbd2686660445e60daae8d56078cf6f2bf22fe7b4c3e005f550e7c17a2d56937c859d8afc169d98f17fff0f119f248aa0f8ebdd71
|
@@ -32,34 +32,56 @@ module Belafonte
|
|
32
32
|
"#{parent.full_path} #{signature}"
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
def command_arg
|
36
|
+
if Belafonte::Help::Generator.target == self && has_subcommands?
|
37
|
+
' command'
|
38
|
+
else
|
39
|
+
''
|
40
|
+
end
|
41
|
+
end
|
39
42
|
|
40
|
-
|
41
|
-
|
43
|
+
def display_flags(cmd)
|
44
|
+
if has_flags?
|
45
|
+
" [#{cmd} options]"
|
46
|
+
else
|
47
|
+
''
|
42
48
|
end
|
49
|
+
end
|
43
50
|
|
44
|
-
|
45
|
-
|
51
|
+
def display_args
|
52
|
+
if has_args?
|
53
|
+
" #{non_command_args.map(&:name).map(&:to_s).join(' ')}"
|
54
|
+
else
|
55
|
+
''
|
46
56
|
end
|
57
|
+
end
|
47
58
|
|
48
|
-
|
59
|
+
def signature
|
60
|
+
display_title.tap {|cmd|
|
61
|
+
return cmd + display_flags(cmd) + display_args + command_arg
|
62
|
+
}
|
49
63
|
end
|
50
64
|
|
51
65
|
def has_flags?
|
52
66
|
configured_switches.any? || configured_options.any?
|
53
67
|
end
|
54
68
|
|
69
|
+
def non_command_args
|
70
|
+
configured_args.reject {|arg| arg.name.to_sym == :command}
|
71
|
+
end
|
72
|
+
|
55
73
|
def has_args?
|
56
|
-
|
74
|
+
non_command_args.any?
|
57
75
|
end
|
58
76
|
|
59
77
|
def has_subcommands?
|
60
78
|
configured_subcommands.any?
|
61
79
|
end
|
62
80
|
|
81
|
+
def help_flag
|
82
|
+
@help_flag ||= Belafonte::Switch.new(name: :help, short: 'h', long: 'help', description: 'Shows this message')
|
83
|
+
end
|
84
|
+
|
63
85
|
def sorted_flags
|
64
86
|
(configured_switches + configured_options).sort {|a,b| a.name <=> b.name}
|
65
87
|
end
|
@@ -6,8 +6,16 @@ require 'belafonte/help/command_extensions'
|
|
6
6
|
module Belafonte
|
7
7
|
module Help
|
8
8
|
class Generator
|
9
|
+
def self.set_target(app)
|
10
|
+
@target = app
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.target
|
14
|
+
@target
|
15
|
+
end
|
16
|
+
|
9
17
|
def initialize(app)
|
10
|
-
@app = app
|
18
|
+
self.class.set_target(@app = app)
|
11
19
|
app.extend(AppExtensions)
|
12
20
|
@content = name_section + synopsis + options + commands
|
13
21
|
end
|
data/lib/belafonte/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: belafonte
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dennis Walters
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|