super_docopt 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 474289f2c16f5a9c803217ab32273e9e98cf926c600c34564ced2eed2eb827ea
4
+ data.tar.gz: 62f74ba90e03a7d247696515a6ef8f221155a6f149c53f0c8aa7de687778444e
5
+ SHA512:
6
+ metadata.gz: fe882885ec596994f74ff2b2f1eb5137524c46348ce29ef9f2ee38005c03e7f624b351d4bd58341ecbf9be11d8d3c3fffc61bc730aaaf53de6973b5fc6cbcade
7
+ data.tar.gz: ed0777d6c669a0194baa20ac26bb3e2ea4fd450346e997ca30e70b1a8da8472a6340af4c1bfaec776b693eacbac3a63abfbd0ed4e8e2b3a51260fc378d7f1480
data/README.md ADDED
@@ -0,0 +1,2 @@
1
+ Super Docopt
2
+ ==================================================
@@ -0,0 +1,63 @@
1
+ require 'singleton'
2
+ require 'docopt'
3
+
4
+ module SuperDocopt
5
+ class Base
6
+ include Singleton
7
+
8
+ VERSION = '0.0.1'
9
+
10
+ attr_accessor :version, :docopt, :subcommands
11
+
12
+ def self.execute(argv=[])
13
+ instance.execute_cli argv
14
+ end
15
+
16
+ def self.version(version)
17
+ instance.version = version
18
+ end
19
+
20
+ def self.docopt(path)
21
+ instance.docopt = path
22
+ end
23
+
24
+ def self.subcommands(list)
25
+ instance.subcommands = list
26
+ end
27
+
28
+ def execute_cli(argv=[])
29
+ doc = File.read docopt
30
+ begin
31
+ args = Docopt::docopt(doc, argv: argv, version: version)
32
+ handle_subcommand args
33
+ rescue Docopt::Exit => e
34
+ puts e.message
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def handle_subcommand(args)
41
+ subcommands.each do |subcommand|
42
+ command = subcommand.to_s
43
+ method = subcommand.to_s
44
+
45
+ if subcommand.is_a? Hash
46
+ command = subcommand.keys.first.to_s
47
+ method = subcommand.values.first.to_s
48
+ end
49
+
50
+ command = command.gsub '_', '-'
51
+ method = method.gsub '-', '_'
52
+
53
+ if args[command]
54
+ raise NotImplementedError,
55
+ "Please implement ##{method}" unless respond_to? method
56
+
57
+ send method, args
58
+ return
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,3 @@
1
+ module SuperDocopt
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1 @@
1
+ require 'super_docopt/base'
metadata ADDED
@@ -0,0 +1,159 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: super_docopt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Danny Ben Shitrit
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-02-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: docopt
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: runfile
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: runfile-tasks
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec_fixtures
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.15'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.15'
97
+ - !ruby/object:Gem::Dependency
98
+ name: byebug
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '9.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '9.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: require_all
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.5'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.5'
125
+ description: Create command line applications with docopt
126
+ email: db@dannyben.com
127
+ executables: []
128
+ extensions: []
129
+ extra_rdoc_files: []
130
+ files:
131
+ - README.md
132
+ - lib/super_docopt.rb
133
+ - lib/super_docopt/base.rb
134
+ - lib/super_docopt/version.rb
135
+ homepage: https://github.com/DannyBen/super_docopt
136
+ licenses:
137
+ - MIT
138
+ metadata: {}
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: 2.0.0
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ requirements: []
154
+ rubyforge_project:
155
+ rubygems_version: 2.7.3
156
+ signing_key:
157
+ specification_version: 4
158
+ summary: Docopt extension for easy command line applications
159
+ test_files: []