hadron 0.1.2 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3635b4c290e0c0541d93b3417b3e670e41a399d06e7ebfd58c646aacb0aa0017
4
- data.tar.gz: 6ee4dbe5fa63f9811af0acd69a1858a54aeb28f57f2c2320e806426d55a2f447
3
+ metadata.gz: 8d100356d8e2274c4bf905faf27dfe83fedbd0a4d2d04a2c27d25d6a9448e687
4
+ data.tar.gz: 0502ca57031a8040518e06036759ccd73eff72c2f29a75e532c5de8d37e19c0a
5
5
  SHA512:
6
- metadata.gz: 77f68999a1921eb7ed0e0c6916ecdcb184ba4084b3abdd2e1cb92f6971d528ace8daed32d9c0c8d4edda5c0e07ff8c5db4cf40f96744f114a5ff5ae4a6cba722
7
- data.tar.gz: fc18af214068259c36c9e0f121acd97986c0fd63a1e4ac2406b9f33f762a650ac1126b0928090b3adbcfd2510a069a994b764928abb340d02a7ba25825c1f6b1
6
+ metadata.gz: 3d6190786df02e902da5132e916c9a98079b80cab0062025a5b104597fcc19e030c38a6f685582f69f979faeef46c36f77b2cd14f89abcdfa77f6f4f5b424524
7
+ data.tar.gz: c2b25b3debf03274a7eb30eb888be747a3dccf3762a5a7a7a2af6b41a03b64fb8aef5296992a610b32b93efbcb07059a88294eb9e7081402750d40390ceee98d
data/Gemfile CHANGED
@@ -9,4 +9,3 @@ gem "proto_dsl", "~> 0.1.1"
9
9
  gem "rake", "~> 13.0"
10
10
  gem "rspec", "~> 3.0"
11
11
  gem "rubocop", "~> 1.21"
12
- gem "thor", "~> 1.2"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hadron (0.1.2)
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 ADDED
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'hadron'
4
+
5
+ cli = Hadron::CommandLine.new
6
+
7
+ # Define the `create` subcommand
8
+ cli.command :create do |c|
9
+ c.desc "Create a new project"
10
+ c.arg_name "project_name"
11
+
12
+ c.action do |args, options|
13
+ project_name = args.first
14
+ Hadron.create_project(project_name)
15
+ end
16
+ end
17
+
18
+ # Define the `db` subcommand
19
+ cli.command :db do |c|
20
+ # Define the `create` subcommand for `db`
21
+ c.command :create do |create|
22
+ create.desc "Create a database"
23
+ create.action do |args, options|
24
+ Hadron.create_database
25
+ end
26
+ end
27
+
28
+ # Define the `migrate` subcommand for `db`
29
+ c.command :migrate do |migrate|
30
+ migrate.desc "Migrate a database"
31
+ migrate.action do |args, options|
32
+ Hadron.migrate_database
33
+ end
34
+ end
35
+ end
36
+
37
+ # Define the `generate` subcommand
38
+ cli.command :generate do |c|
39
+ c.desc "Generate boilerplate code"
40
+
41
+ # Define the `scaffold` subcommand for `generate`
42
+ c.command :scaffold do |scaffold|
43
+ scaffold.desc "Generate scaffold code"
44
+ scaffold.arg_name "scaffold_name"
45
+
46
+ scaffold.action do |args, options|
47
+ scaffold_name = args.first
48
+ Hadron.generate_scaffold(scaffold_name)
49
+ end
50
+ end
51
+ end
52
+
53
+ cli.run(ARGV)
data/hadron.gemspec CHANGED
@@ -26,8 +26,8 @@ Gem::Specification.new do |spec|
26
26
  (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
27
27
  end
28
28
  end
29
- spec.bindir = "exe"
30
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
+
30
+ spec.executables = ["hadron"]
31
31
  spec.require_paths = ["lib"]
32
32
 
33
33
  # Uncomment to register a new dependency of your gem
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hadron
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.5"
5
5
  end
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hadron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvance
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2022-12-08 00:00:00.000000000 Z
12
12
  dependencies: []
@@ -14,7 +14,8 @@ description: Ruby framework called Hadron that allows you to work with gRPC Ruby
14
14
  easily.
15
15
  email:
16
16
  - kerandisylvance@gmail.com
17
- executables: []
17
+ executables:
18
+ - hadron
18
19
  extensions: []
19
20
  extra_rdoc_files: []
20
21
  files:
@@ -26,8 +27,11 @@ files:
26
27
  - Gemfile.lock
27
28
  - README.md
28
29
  - Rakefile
30
+ - bin/hadron
29
31
  - hadron.gemspec
30
32
  - lib/hadron.rb
33
+ - lib/hadron/command.rb
34
+ - lib/hadron/command_line.rb
31
35
  - lib/hadron/version.rb
32
36
  homepage: https://github.com/Sylvance/hadron
33
37
  licenses: []