dracula 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/dracula.rb +50 -46
- data/lib/dracula/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf8af3fa8ce0d0773e44cf93b3fe96c801ab73c9
|
4
|
+
data.tar.gz: 748c0857159a8f4f554c47c659a4ce39f481c5ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b419f1370ad664f0d74954ec949817a1523928f640db92917a74d196ec4eb7b47f4ccf25aded8f760623cff0442c4e6bc67cd45167572661eec7081b38087f0e
|
7
|
+
data.tar.gz: ee539053a23e58bf2de318da6418202e59135cb084c042a81711b623523813ba5b4f22337ed974e3bbcbef041aa98ae5f2a5640edee6b4213b1536f604cf5b0a
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Dracula
|
2
2
|
|
3
|
-
[![Build Status](https://semaphoreci.com/api/v1/
|
3
|
+
[![Build Status](https://semaphoreci.com/api/v1/renderedtext/dracula/branches/master/badge.svg)](https://semaphoreci.com/renderedtext/dracula)
|
4
4
|
|
5
5
|
## Usage
|
6
6
|
|
data/lib/dracula.rb
CHANGED
@@ -6,69 +6,73 @@ class Dracula
|
|
6
6
|
require "dracula/namespace"
|
7
7
|
require "dracula/ui"
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
class << self
|
10
|
+
def program_name(name = nil)
|
11
|
+
if name.nil?
|
12
|
+
@@program_name || "dracula" # getter
|
13
|
+
else
|
14
|
+
@@program_name = name # setter
|
15
|
+
end
|
14
16
|
end
|
15
|
-
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
def start(args)
|
19
|
+
if args.empty? || (args.size == 1 && args[0] == "help")
|
20
|
+
namespace.help
|
21
|
+
else
|
22
|
+
action = args[0] == "help" ? :help : :run
|
22
23
|
|
23
|
-
|
24
|
-
|
24
|
+
if args[0] == "help"
|
25
|
+
action = :help
|
25
26
|
|
26
|
-
|
27
|
+
args.shift # drop 'help'
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
command = args.shift
|
30
|
+
params = args
|
31
|
+
else
|
32
|
+
action = :run
|
33
|
+
command = args.shift
|
34
|
+
params = args
|
35
|
+
end
|
36
|
+
|
37
|
+
namespace.dispatch(command.split(":"), params, action)
|
34
38
|
end
|
39
|
+
end
|
35
40
|
|
36
|
-
|
41
|
+
def namespace
|
42
|
+
@namespace ||= Dracula::Namespace.new(self)
|
37
43
|
end
|
38
|
-
end
|
39
44
|
|
40
|
-
|
41
|
-
|
42
|
-
|
45
|
+
def option(name, params = {})
|
46
|
+
@options ||= []
|
47
|
+
@options << Command::Option.new(name, params)
|
48
|
+
end
|
43
49
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
50
|
+
def long_desc(description)
|
51
|
+
@long_desc = description
|
52
|
+
end
|
48
53
|
|
49
|
-
|
50
|
-
|
51
|
-
|
54
|
+
def desc(name, description)
|
55
|
+
@desc = Command::Desc.new(name, description)
|
56
|
+
end
|
52
57
|
|
53
|
-
|
54
|
-
|
55
|
-
|
58
|
+
def register(name, description, klass)
|
59
|
+
klass.namespace.name = name
|
60
|
+
klass.namespace.description = description
|
56
61
|
|
57
|
-
|
58
|
-
|
59
|
-
klass.namespace.description = description
|
62
|
+
namespace.add_subcommand(klass.namespace)
|
63
|
+
end
|
60
64
|
|
61
|
-
|
62
|
-
end
|
65
|
+
private
|
63
66
|
|
64
|
-
|
65
|
-
|
67
|
+
def method_added(method_name)
|
68
|
+
command = Command.new(self, method_name, @desc, @long_desc, @options)
|
66
69
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
+
@desc = nil
|
71
|
+
@long_desc = nil
|
72
|
+
@options = nil
|
70
73
|
|
71
|
-
|
74
|
+
namespace.add_command(command)
|
75
|
+
end
|
72
76
|
end
|
73
77
|
|
74
78
|
attr_reader :options
|
data/lib/dracula/version.rb
CHANGED