hadron 0.1.3 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/Gemfile.lock +1 -3
- data/bin/hadron +7 -4
- data/lib/hadron/command.rb +45 -0
- data/lib/hadron/command_line.rb +28 -0
- data/lib/hadron/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d100356d8e2274c4bf905faf27dfe83fedbd0a4d2d04a2c27d25d6a9448e687
|
4
|
+
data.tar.gz: 0502ca57031a8040518e06036759ccd73eff72c2f29a75e532c5de8d37e19c0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d6190786df02e902da5132e916c9a98079b80cab0062025a5b104597fcc19e030c38a6f685582f69f979faeef46c36f77b2cd14f89abcdfa77f6f4f5b424524
|
7
|
+
data.tar.gz: c2b25b3debf03274a7eb30eb888be747a3dccf3762a5a7a7a2af6b41a03b64fb8aef5296992a610b32b93efbcb07059a88294eb9e7081402750d40390ceee98d
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hadron (0.1.
|
4
|
+
hadron (0.1.5)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -43,7 +43,6 @@ GEM
|
|
43
43
|
rubocop-ast (1.24.0)
|
44
44
|
parser (>= 3.1.1.0)
|
45
45
|
ruby-progressbar (1.11.0)
|
46
|
-
thor (1.2.1)
|
47
46
|
unicode-display_width (2.3.0)
|
48
47
|
|
49
48
|
PLATFORMS
|
@@ -56,7 +55,6 @@ DEPENDENCIES
|
|
56
55
|
rake (~> 13.0)
|
57
56
|
rspec (~> 3.0)
|
58
57
|
rubocop (~> 1.21)
|
59
|
-
thor (~> 1.2)
|
60
58
|
|
61
59
|
BUNDLED WITH
|
62
60
|
2.3.15
|
data/bin/hadron
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require 'thor'
|
4
3
|
require 'hadron'
|
5
4
|
|
5
|
+
cli = Hadron::CommandLine.new
|
6
|
+
|
6
7
|
# Define the `create` subcommand
|
7
|
-
command :create do |c|
|
8
|
+
cli.command :create do |c|
|
8
9
|
c.desc "Create a new project"
|
9
10
|
c.arg_name "project_name"
|
10
11
|
|
@@ -15,7 +16,7 @@ command :create do |c|
|
|
15
16
|
end
|
16
17
|
|
17
18
|
# Define the `db` subcommand
|
18
|
-
command :db do |c|
|
19
|
+
cli.command :db do |c|
|
19
20
|
# Define the `create` subcommand for `db`
|
20
21
|
c.command :create do |create|
|
21
22
|
create.desc "Create a database"
|
@@ -34,7 +35,7 @@ command :db do |c|
|
|
34
35
|
end
|
35
36
|
|
36
37
|
# Define the `generate` subcommand
|
37
|
-
command :generate do |c|
|
38
|
+
cli.command :generate do |c|
|
38
39
|
c.desc "Generate boilerplate code"
|
39
40
|
|
40
41
|
# Define the `scaffold` subcommand for `generate`
|
@@ -48,3 +49,5 @@ command :generate do |c|
|
|
48
49
|
end
|
49
50
|
end
|
50
51
|
end
|
52
|
+
|
53
|
+
cli.run(ARGV)
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Hadron
|
4
|
+
class Command
|
5
|
+
def initialize(name)
|
6
|
+
@name = name
|
7
|
+
@subcommands = {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def desc(description)
|
11
|
+
@description = description
|
12
|
+
end
|
13
|
+
|
14
|
+
def arg_name(name)
|
15
|
+
@arg_name = name
|
16
|
+
end
|
17
|
+
|
18
|
+
def action(&block)
|
19
|
+
@action = block
|
20
|
+
end
|
21
|
+
|
22
|
+
def command(name, &block)
|
23
|
+
cmd = Command.new(name)
|
24
|
+
cmd.instance_eval(&block)
|
25
|
+
@subcommands[name] = cmd
|
26
|
+
end
|
27
|
+
|
28
|
+
def run(args)
|
29
|
+
if @subcommands.empty?
|
30
|
+
# This command has no subcommands, so it must have an action
|
31
|
+
@action.call(args)
|
32
|
+
else
|
33
|
+
# This command has subcommands, so the next argument should be a subcommand name
|
34
|
+
subcmd_name = args.shift
|
35
|
+
subcmd = @subcommands[subcmd_name]
|
36
|
+
|
37
|
+
if subcmd
|
38
|
+
subcmd.run(args)
|
39
|
+
else
|
40
|
+
puts "Unknown subcommand for '#{@name}': #{subcmd_name}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "./command"
|
4
|
+
|
5
|
+
module Hadron
|
6
|
+
class CommandLine
|
7
|
+
def initialize
|
8
|
+
@commands = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def command(name, &block)
|
12
|
+
cmd = Command.new(name)
|
13
|
+
cmd.instance_eval(&block)
|
14
|
+
@commands[name] = cmd
|
15
|
+
end
|
16
|
+
|
17
|
+
def run(args)
|
18
|
+
cmd_name = args.shift
|
19
|
+
cmd = @commands[cmd_name]
|
20
|
+
|
21
|
+
if cmd
|
22
|
+
cmd.run(args)
|
23
|
+
else
|
24
|
+
puts "Unknown command: #{cmd_name}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/hadron/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hadron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvance
|
@@ -30,6 +30,8 @@ files:
|
|
30
30
|
- bin/hadron
|
31
31
|
- hadron.gemspec
|
32
32
|
- lib/hadron.rb
|
33
|
+
- lib/hadron/command.rb
|
34
|
+
- lib/hadron/command_line.rb
|
33
35
|
- lib/hadron/version.rb
|
34
36
|
homepage: https://github.com/Sylvance/hadron
|
35
37
|
licenses: []
|