dracula 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +81 -1
- data/lib/dracula.rb +5 -0
- data/lib/dracula/command.rb +4 -0
- data/lib/dracula/structure.rb +54 -0
- data/lib/dracula/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe10f1e79a3051535e035ed137b1c942074d57c2
|
4
|
+
data.tar.gz: 95c3e7dde4bcce0352411762a6d4d52daa1f213a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6daca3596bef3115a8749c3e868de3cb0b33b3d3ab851bbbcf395d2463a13ce11f3e3051fd14ee3b33a3a6aeb1cb11e03e52ecc1b63363eac7e231b5d52442b6
|
7
|
+
data.tar.gz: 86ff8358a768d0718580645af64705cae2f40153a011517a4b20de66babb26f6ca8e852541545bd408c1929c1725ca554e3bf397c67d776b5542cf5a7b3bb72a
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ app calendar:events:list
|
|
19
19
|
app calendar:events:add
|
20
20
|
```
|
21
21
|
|
22
|
-
For help, you can
|
22
|
+
For help, you can run:
|
23
23
|
|
24
24
|
``` txt
|
25
25
|
app help <command-name>
|
@@ -208,6 +208,85 @@ $ cli greetings:bye
|
|
208
208
|
Bye!
|
209
209
|
```
|
210
210
|
|
211
|
+
## Generating JSON structure from your interface
|
212
|
+
|
213
|
+
Dracula allows you to generate documentation based on the interface you have
|
214
|
+
defined in your code. The output is a hash.
|
215
|
+
|
216
|
+
An example output generated from the [example CLI interface](spec/example_cli.rb)
|
217
|
+
is the following:
|
218
|
+
|
219
|
+
``` ruby
|
220
|
+
CLI.docs
|
221
|
+
|
222
|
+
=>
|
223
|
+
|
224
|
+
{
|
225
|
+
:name => "",
|
226
|
+
|
227
|
+
:commands => [
|
228
|
+
{
|
229
|
+
:name => "login",
|
230
|
+
:desc => "Log in to the cli",
|
231
|
+
:long_desc => "Log in to the app from the command line.\n",
|
232
|
+
:shell => "git login --username USERNAME --password PASSWORD",
|
233
|
+
:options => [
|
234
|
+
{ :name => "username", :required => true, :type => "string", :alias => "u", :default => nil },
|
235
|
+
{ :name => "password", :required => true, :type => "string", :alias => "p", :default => nil },
|
236
|
+
{ :name => "verbose", :required => false, :type => "boolean", :alias => "v", :default => false }
|
237
|
+
]
|
238
|
+
}
|
239
|
+
],
|
240
|
+
|
241
|
+
:namespaces => [
|
242
|
+
:name => "teams",
|
243
|
+
|
244
|
+
:commands => [
|
245
|
+
{
|
246
|
+
:name => "list",
|
247
|
+
:long_desc => "",
|
248
|
+
:desc => "List teams in an organization",
|
249
|
+
:shell => "git teams:list ORG",
|
250
|
+
:options => []
|
251
|
+
},
|
252
|
+
{
|
253
|
+
:name => "info",
|
254
|
+
:long_desc => "",
|
255
|
+
:desc => "Show info for a team",
|
256
|
+
:shell => "git teams:info TEAM",
|
257
|
+
:options => []
|
258
|
+
}
|
259
|
+
],
|
260
|
+
|
261
|
+
:namespaces => [
|
262
|
+
:name => "projects",
|
263
|
+
|
264
|
+
:commands => [
|
265
|
+
{
|
266
|
+
:name => "add",
|
267
|
+
:long_desc => "",
|
268
|
+
:desc => "Add a project to the team",
|
269
|
+
:shell => "git teams:projects:add TEAM PROJECT",
|
270
|
+
:options => []
|
271
|
+
},
|
272
|
+
{
|
273
|
+
:name => "list",
|
274
|
+
:desc => "List projects in a team",
|
275
|
+
:long_desc => "",
|
276
|
+
:shell => "git teams:projects:list TEAM",
|
277
|
+
:options => []
|
278
|
+
}
|
279
|
+
],
|
280
|
+
|
281
|
+
:namespaces => []
|
282
|
+
]
|
283
|
+
]
|
284
|
+
}
|
285
|
+
```
|
286
|
+
|
287
|
+
The output should be suitable for generating markdown or html documentation for
|
288
|
+
your CLI.
|
289
|
+
|
211
290
|
## Development
|
212
291
|
|
213
292
|
After checking out the repo, run `bin/setup` to install dependencies. Then,
|
@@ -232,3 +311,4 @@ of conduct.
|
|
232
311
|
|
233
312
|
The gem is available as open source under the terms of
|
234
313
|
the [MIT License](http://opensource.org/licenses/MIT).
|
314
|
+
|
data/lib/dracula.rb
CHANGED
@@ -8,6 +8,7 @@ class Dracula
|
|
8
8
|
require "dracula/command_help"
|
9
9
|
require "dracula/namespace"
|
10
10
|
require "dracula/namespace_help"
|
11
|
+
require "dracula/structure"
|
11
12
|
|
12
13
|
class << self
|
13
14
|
def program_name(name = nil)
|
@@ -41,6 +42,10 @@ class Dracula
|
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
45
|
+
def structure
|
46
|
+
Dracula::Structure.new(namespace).generate
|
47
|
+
end
|
48
|
+
|
44
49
|
def namespace
|
45
50
|
@namespace ||= Dracula::Namespace.new(self)
|
46
51
|
end
|
data/lib/dracula/command.rb
CHANGED
@@ -0,0 +1,54 @@
|
|
1
|
+
class Dracula
|
2
|
+
class Structure
|
3
|
+
|
4
|
+
attr_reader :namespace
|
5
|
+
|
6
|
+
def initialize(namespace)
|
7
|
+
@namespace = namespace
|
8
|
+
end
|
9
|
+
|
10
|
+
def generate
|
11
|
+
{
|
12
|
+
:name => namespace.name.to_s,
|
13
|
+
:commands => @namespace.commands.map { |cmd| command_docs(cmd) },
|
14
|
+
:namespaces => @namespace.subcommands.map { |sc| Dracula::Structure.new(sc).generate }
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def command_docs(command)
|
21
|
+
{
|
22
|
+
:name => command.name,
|
23
|
+
:desc => command.description,
|
24
|
+
:long_desc => command.long_desc.to_s,
|
25
|
+
:shell => command_shell(command),
|
26
|
+
:options => command.options.map do |option|
|
27
|
+
{
|
28
|
+
:name => option.name.to_s,
|
29
|
+
:required => option.required?,
|
30
|
+
:type => option.type.to_s,
|
31
|
+
:alias => option.alias_name,
|
32
|
+
:default => option.default_value
|
33
|
+
}
|
34
|
+
end
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
# shows how to calll the command from the shell
|
39
|
+
def command_shell(command)
|
40
|
+
args = command.arguments.join(" ")
|
41
|
+
options = command.options.select(&:required?).map(&:long_name_banner).join(" ")
|
42
|
+
|
43
|
+
elements = [
|
44
|
+
Dracula.program_name,
|
45
|
+
command.full_name,
|
46
|
+
args,
|
47
|
+
options
|
48
|
+
]
|
49
|
+
|
50
|
+
elements.select { |element| element != "" }.join(" ")
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
data/lib/dracula/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dracula
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Šarčević
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -75,6 +75,7 @@ files:
|
|
75
75
|
- lib/dracula/flag.rb
|
76
76
|
- lib/dracula/namespace.rb
|
77
77
|
- lib/dracula/namespace_help.rb
|
78
|
+
- lib/dracula/structure.rb
|
78
79
|
- lib/dracula/ui.rb
|
79
80
|
- lib/dracula/version.rb
|
80
81
|
homepage: https://github.com/renderedtext/dracula
|