hanami-cli 0.3.1 → 1.0.0.alpha1

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: 60885ef66fb058be469d4eedc0d6bb7d87313cd41fd07e901b931ae4843fde94
4
- data.tar.gz: 0f94f42aa87986edaf8b9664b09f9cdc0fa301a68c27ce8b6b75672db6201883
3
+ metadata.gz: 0fe57714d6c897c21dd896eac31b8075fc52a7d747a2b9d7745bddebc4233818
4
+ data.tar.gz: 76217ba7ae795a50d4c37c92f837d826f009b178cf8f2d169985cfde35abff8f
5
5
  SHA512:
6
- metadata.gz: fd337cf63a535c96d76bcd156947542484a8c5f6a7a5d36c305c9e5b780ebbcc2fa150ee82eacb0c039805ac8d3b13ef05eaf5addba81481e4da9a0e39210fae
7
- data.tar.gz: febc46f538af4d8d2a0676f97be14e4571a3e407345a07a84a748dd877a4753b5ddd2713be866e7b294eddfa0a79ef20e39b308138fc5626108f46ae5d9aff24
6
+ metadata.gz: 3e61b952023ef34ce48c2c24a3108e3b9087c7712e961a4af0c6eaee42aa707f661aba35f733468aec27ee02924578c9e65a12f499fc5a00e288666561c584fb
7
+ data.tar.gz: 9d04ca91f9372567f72d852222e82caf639019df436c9c58b31fd828ad841ec3b75f93bdce08c585ac55345e71478c27f05cf4b88fdf8e3e88ba50bcbfcdd279
@@ -4,56 +4,6 @@
4
4
  #
5
5
  version: 2
6
6
  jobs:
7
- "ruby-2.3":
8
- docker:
9
- - image: hanami/ruby-2.3
10
- working_directory: ~/hanami-utils
11
- steps:
12
- - checkout
13
- # Download and cache dependencies
14
- - restore_cache:
15
- keys:
16
- - v1-dependencies-{{ checksum "Gemfile.lock" }}
17
- # fallback to using the latest cache if no exact match is found
18
- - v1-dependencies-
19
- - run:
20
- name: install dependencies
21
- command: |
22
- bundle install --jobs=4 --retry=3 --path vendor/bundle
23
- - save_cache:
24
- paths:
25
- - ./vendor/bundle
26
- key: v1-dependencies-{{ checksum "Gemfile.lock" }}
27
- # run tests!
28
- - run:
29
- name: run tests
30
- command: |
31
- ./script/ci
32
- "ruby-2.4":
33
- docker:
34
- - image: hanami/ruby-2.4
35
- working_directory: ~/hanami-utils
36
- steps:
37
- - checkout
38
- # Download and cache dependencies
39
- - restore_cache:
40
- keys:
41
- - v1-dependencies-{{ checksum "Gemfile.lock" }}
42
- # fallback to using the latest cache if no exact match is found
43
- - v1-dependencies-
44
- - run:
45
- name: install dependencies
46
- command: |
47
- bundle install --jobs=4 --retry=3 --path vendor/bundle
48
- - save_cache:
49
- paths:
50
- - ./vendor/bundle
51
- key: v1-dependencies-{{ checksum "Gemfile.lock" }}
52
- # run tests!
53
- - run:
54
- name: run tests
55
- command: |
56
- ./script/ci
57
7
  "ruby-2.5":
58
8
  docker:
59
9
  - image: hanami/ruby-2.5
@@ -104,64 +54,10 @@ jobs:
104
54
  name: run tests
105
55
  command: |
106
56
  ./script/ci
107
- "jruby-9.1":
108
- docker:
109
- - image: hanami/jruby-9.1
110
- working_directory: ~/hanami-utils
111
- steps:
112
- - checkout
113
- # Download and cache dependencies
114
- - restore_cache:
115
- keys:
116
- - v1-dependencies-{{ checksum "Gemfile.lock" }}
117
- # fallback to using the latest cache if no exact match is found
118
- - v1-dependencies-
119
- - run:
120
- name: install dependencies
121
- command: |
122
- bundle install --jobs=4 --retry=3 --path vendor/bundle
123
- - save_cache:
124
- paths:
125
- - ./vendor/bundle
126
- key: v1-dependencies-{{ checksum "Gemfile.lock" }}
127
- # run tests!
128
- - run:
129
- name: run tests
130
- command: |
131
- ./script/ci
132
- "jruby-9.2":
133
- docker:
134
- - image: hanami/jruby-9.2
135
- working_directory: ~/hanami-utils
136
- steps:
137
- - checkout
138
- # Download and cache dependencies
139
- - restore_cache:
140
- keys:
141
- - v1-dependencies-{{ checksum "Gemfile.lock" }}
142
- # fallback to using the latest cache if no exact match is found
143
- - v1-dependencies-
144
- - run:
145
- name: install dependencies
146
- command: |
147
- bundle install --jobs=4 --retry=3 --path vendor/bundle
148
- - save_cache:
149
- paths:
150
- - ./vendor/bundle
151
- key: v1-dependencies-{{ checksum "Gemfile.lock" }}
152
- # run tests!
153
- - run:
154
- name: run tests
155
- command: |
156
- ./script/ci
157
57
 
158
58
  workflows:
159
59
  version: 2
160
60
  build:
161
61
  jobs:
162
- - "ruby-2.3"
163
- - "ruby-2.4"
164
62
  - "ruby-2.5"
165
63
  - "ruby-2.6"
166
- - "jruby-9.1"
167
- - "jruby-9.2"
@@ -1,4 +1,4 @@
1
1
  # Please keep AllCops, Bundler, Style, Metrics groups and then order cops
2
2
  # alphabetically
3
3
  inherit_from:
4
- - https://raw.githubusercontent.com/hanami/devtools/master/.rubocop.yml
4
+ - https://raw.githubusercontent.com/hanami/devtools/master/.rubocop-unstable.yml
@@ -5,19 +5,13 @@ before_script:
5
5
  - gem update --system
6
6
  script: ./script/ci
7
7
  rvm:
8
- - 2.3.8
9
- - 2.4.5
10
- - 2.5.3
11
- - 2.6.0
12
- - jruby-9.1.9.0
8
+ - 2.5
9
+ - 2.6
13
10
  - ruby-head
14
- - jruby-head
15
11
 
16
12
  matrix:
17
13
  allow_failures:
18
14
  - rvm: ruby-head
19
- - rvm: jruby-head
20
- - rvm: jruby-9.1.9.0
21
15
 
22
16
  notifications:
23
17
  webhooks:
@@ -1,6 +1,14 @@
1
1
  # Hanami::CLI
2
2
  General purpose Command Line Interface (CLI) framework for Ruby
3
3
 
4
+ ## v1.0.0.alpha1 - 2019-01-30
5
+ ### Added
6
+ - [Luca Guidi] Inheritng from subclasses of `Hanami::CLI::Command`, allows to inherit arguments, options, description, and examples.
7
+ - [Luca Guidi] Allow to use `super` from `#call`
8
+
9
+ ### Changed
10
+ - [Luca Guidi] Drop support for Ruby: MRI 2.3, and 2.4.
11
+
4
12
  ## v0.3.1 - 2019-01-18
5
13
  ### Added
6
14
  - [Luca Guidi] Official support for Ruby: MRI 2.6
data/Gemfile CHANGED
@@ -1,11 +1,12 @@
1
- source 'https://rubygems.org'
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
2
4
  gemspec
3
5
 
4
- unless ENV['CI']
5
- gem 'byebug', require: false, platforms: :mri
6
- gem 'yard', require: false
6
+ unless ENV["CI"]
7
+ gem "byebug", require: false, platforms: :mri
8
+ gem "yard", require: false
7
9
  end
8
10
 
9
- gem 'hanami-utils', '~> 1.3', require: false, git: 'https://github.com/hanami/utils.git', branch: 'master'
10
-
11
- gem 'hanami-devtools', require: false, git: 'https://github.com/hanami/devtools.git'
11
+ gem "hanami-utils", "~> 2.0.alpha", require: false, git: "https://github.com/hanami/utils.git", branch: "unstable"
12
+ gem "hanami-devtools", require: false, git: "https://github.com/hanami/devtools.git"
data/README.md CHANGED
@@ -24,7 +24,7 @@ General purpose Command Line Interface (CLI) framework for Ruby.
24
24
 
25
25
  ## Rubies
26
26
 
27
- __Hanami::CLI__ supports Ruby (MRI) 2.3+, JRuby 9.1.5.0+
27
+ __Hanami::CLI__ supports Ruby (MRI) 2.5+
28
28
 
29
29
  ## Installation
30
30
 
@@ -633,4 +633,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/hanami
633
633
 
634
634
  ## Copyright
635
635
 
636
- Copyright © 2017 Luca Guidi – Released under MIT License
636
+ Copyright © 2017-2019 Luca Guidi – Released under MIT License
data/Rakefile CHANGED
@@ -1,15 +1,17 @@
1
- require 'rake'
2
- require 'bundler/gem_tasks'
3
- require 'rspec/core/rake_task'
4
- require 'hanami/devtools/rake_tasks'
1
+ # frozen_string_literal: true
2
+
3
+ require "rake"
4
+ require "bundler/gem_tasks"
5
+ require "rspec/core/rake_task"
6
+ require "hanami/devtools/rake_tasks"
5
7
 
6
8
  namespace :spec do
7
9
  RSpec::Core::RakeTask.new(:unit) do |task|
8
- file_list = FileList['spec/**/*_spec.rb']
10
+ file_list = FileList["spec/**/*_spec.rb"]
9
11
  file_list = file_list.exclude("spec/{integration,isolation}/**/*_spec.rb")
10
12
 
11
13
  task.pattern = file_list
12
14
  end
13
15
  end
14
16
 
15
- task default: 'spec:unit'
17
+ task default: "spec:unit"
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require "bundler/setup"
4
5
  require "hanami/cli"
@@ -1,6 +1,8 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("../lib", __FILE__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'hanami/cli/version'
5
+ require "hanami/cli/version"
4
6
 
5
7
  Gem::Specification.new do |spec|
6
8
  spec.name = "hanami-cli"
@@ -13,18 +15,19 @@ Gem::Specification.new do |spec|
13
15
  spec.description = "Hanami framework to build command line interfaces with Ruby"
14
16
  spec.homepage = "http://hanamirb.org"
15
17
 
16
- spec.metadata['allowed_push_host'] = "https://rubygems.org"
17
- spec.metadata['source_code_uri'] = "https://github.com/hanami/cli"
18
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
19
+ spec.metadata["source_code_uri"] = "https://github.com/hanami/cli"
18
20
 
19
21
  spec.bindir = "exe"
20
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
23
  spec.require_paths = ["lib"]
24
+ spec.required_ruby_version = ">= 2.5.0"
22
25
 
23
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
24
27
  f.match(%r{^(test|spec|features)/})
25
28
  end
26
29
 
27
- spec.add_dependency "hanami-utils", "~> 1.3"
30
+ spec.add_dependency "hanami-utils", "~> 2.0.alpha"
28
31
  spec.add_dependency "concurrent-ruby", "~> 1.0"
29
32
 
30
33
  spec.add_development_dependency "bundler", ">= 1.6", "< 3"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Hanami
2
4
  #
3
5
  # @since 0.1.0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "hanami/cli/program_name"
2
4
 
3
5
  module Hanami
@@ -81,8 +83,8 @@ module Hanami
81
83
  required_arguments = command.required_arguments
82
84
  optional_arguments = command.optional_arguments
83
85
 
84
- required = required_arguments.map { |arg| arg.name.upcase }.join(' ') if required_arguments.any?
85
- optional = optional_arguments.map { |arg| "[#{arg.name.upcase}]" }.join(' ') if optional_arguments.any?
86
+ required = required_arguments.map { |arg| arg.name.upcase }.join(" ") if required_arguments.any?
87
+ optional = optional_arguments.map { |arg| "[#{arg.name.upcase}]" }.join(" ") if optional_arguments.any?
86
88
  result = [required, optional].compact
87
89
 
88
90
  " #{result.join(' ')}" unless result.empty?
@@ -1,6 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "forwardable"
2
4
  require "concurrent/array"
3
5
  require "hanami/cli/option"
6
+ require "hanami/utils/class_attribute"
4
7
 
5
8
  module Hanami
6
9
  class CLI
@@ -20,32 +23,62 @@ module Hanami
20
23
  module ClassMethods
21
24
  # @since 0.1.0
22
25
  # @api private
26
+ #
27
+ # rubocop:disable Metrics/MethodLength
23
28
  def self.extended(base)
24
29
  super
30
+ return unless extend?(base)
25
31
 
26
32
  base.class_eval do
27
- @description = nil
28
- @examples = Concurrent::Array.new
29
- @arguments = Concurrent::Array.new
30
- @options = Concurrent::Array.new
31
- end
32
- end
33
+ include Utils::ClassAttribute
33
34
 
34
- # @since 0.1.0
35
- # @api private
36
- attr_reader :description
35
+ class_attribute :description
36
+ self.description = nil
37
37
 
38
- # @since 0.1.0
39
- # @api private
40
- attr_reader :examples
38
+ class_attribute :examples
39
+ self.examples = Concurrent::Array.new
41
40
 
42
- # @since 0.1.0
43
- # @api private
44
- attr_reader :arguments
41
+ class_attribute :arguments
42
+ self.arguments = Concurrent::Array.new
45
43
 
46
- # @since 0.1.0
44
+ class_attribute :options
45
+ self.options = Concurrent::Array.new
46
+ end
47
+ end
48
+ # rubocop:enable Metrics/MethodLength
49
+
50
+ # Only add class attributes if a command is inheriting directly from `Hanami::CLI::Command`.
51
+ # In this way, its subclasses can inherit arguments/options from the parent class.
52
+ #
53
+ # @return [TrueClass,FalseClass] the result of the check
54
+ #
55
+ # @since 1.0.0
47
56
  # @api private
48
- attr_reader :options
57
+ #
58
+ # @example
59
+ # # For this class `extend?` will return `true`
60
+ # class Server < Hanami::CLI::Command
61
+ # option :engine
62
+ #
63
+ # def call(**options)
64
+ # # start the server
65
+ # end
66
+ # end
67
+ #
68
+ # # For this class `extend?` will return `false`
69
+ # class ServerReloader < Server
70
+ # option :reload, type: :boolean, default: true
71
+ #
72
+ # def call(**options)
73
+ # reload = options.fetch(:reload)
74
+ # super unless reload
75
+ #
76
+ # # activate reloading
77
+ # end
78
+ # end
79
+ def self.extend?(base)
80
+ base.superclass == Hanami::CLI::Command
81
+ end
49
82
  end
50
83
 
51
84
  # Set the description of the command
@@ -65,7 +98,7 @@ module Hanami
65
98
  # end
66
99
  # end
67
100
  def self.desc(description)
68
- @description = description
101
+ self.description = description
69
102
  end
70
103
 
71
104
  # Describe the usage of the command
@@ -101,7 +134,7 @@ module Hanami
101
134
  # # foo server --port=2306 # Bind to a port
102
135
  # # foo server --no-code-reloading # Disable code reloading
103
136
  def self.example(*examples)
104
- @examples += examples.flatten
137
+ self.examples += examples.flatten
105
138
  end
106
139
 
107
140
  # Specify an argument
@@ -195,7 +228,7 @@ module Hanami
195
228
  # # Options:
196
229
  # # --help, -h # Print this help
197
230
  def self.argument(name, options = {})
198
- @arguments << Argument.new(name, options)
231
+ arguments << Argument.new(name, options)
199
232
  end
200
233
 
201
234
  # Command line option (aka optional argument)
@@ -309,13 +342,13 @@ module Hanami
309
342
  # # Options:
310
343
  # # --port=VALUE, -p VALUE
311
344
  def self.option(name, options = {})
312
- @options << Option.new(name, options)
345
+ self.options << Option.new(name, options)
313
346
  end
314
347
 
315
348
  # @since 0.1.0
316
349
  # @api private
317
350
  def self.params
318
- (@arguments + @options).uniq
351
+ (arguments + options).uniq
319
352
  end
320
353
 
321
354
  # @since 0.1.0
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "concurrent/hash"
2
- require 'hanami/utils/callbacks'
4
+ require "hanami/utils/callbacks"
3
5
 
4
6
  module Hanami
5
7
  class CLI
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "hanami/utils/deprecation"
2
4
 
3
5
  module Hanami
@@ -37,7 +39,7 @@ module Hanami
37
39
  # @since 0.2.1
38
40
  def self.const_missing(name)
39
41
  super unless name == :UnkwnownCommandError
40
- Hanami::Utils::Deprecation.new('UnkwnownCommandError is deprecated, please use UnknownCommandError')
42
+ Hanami::Utils::Deprecation.new("UnkwnownCommandError is deprecated, please use UnknownCommandError")
41
43
  UnknownCommandError
42
44
  end
43
45
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "hanami/utils/string"
2
4
 
3
5
  module Hanami
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "optparse"
2
4
  require "hanami/cli/program_name"
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Hanami
2
4
  class CLI
3
5
  # Program name
@@ -7,7 +9,7 @@ module Hanami
7
9
  module ProgramName
8
10
  # @since 0.1.0
9
11
  # @api private
10
- SEPARATOR = " ".freeze
12
+ SEPARATOR = " "
11
13
 
12
14
  # @since 0.1.0
13
15
  # @api private
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "hanami/cli/command_registry"
2
4
 
3
5
  module Hanami
@@ -260,7 +262,7 @@ module Hanami
260
262
 
261
263
  private
262
264
 
263
- COMMAND_NAME_SEPARATOR = " ".freeze
265
+ COMMAND_NAME_SEPARATOR = " "
264
266
 
265
267
  # @since 0.2.0
266
268
  # @api private
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "hanami/cli/program_name"
2
4
 
3
5
  module Hanami
@@ -9,7 +11,7 @@ module Hanami
9
11
  module Usage
10
12
  # @since 0.1.0
11
13
  # @api private
12
- SUBCOMMAND_BANNER = " [SUBCOMMAND]".freeze
14
+ SUBCOMMAND_BANNER = " [SUBCOMMAND]"
13
15
 
14
16
  # @since 0.1.0
15
17
  # @api private
@@ -50,8 +52,8 @@ module Hanami
50
52
  required_arguments = command.required_arguments
51
53
  optional_arguments = command.optional_arguments
52
54
 
53
- required = required_arguments.map { |arg| arg.name.upcase }.join(' ') if required_arguments.any?
54
- optional = optional_arguments.map { |arg| "[#{arg.name.upcase}]" }.join(' ') if optional_arguments.any?
55
+ required = required_arguments.map { |arg| arg.name.upcase }.join(" ") if required_arguments.any?
56
+ optional = optional_arguments.map { |arg| "[#{arg.name.upcase}]" }.join(" ") if optional_arguments.any?
55
57
  result = [required, optional].compact
56
58
 
57
59
  " #{result.join(' ')}" unless result.empty?
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Hanami
2
4
  class CLI
3
5
  # @since 0.1.0
4
- VERSION = "0.3.1".freeze
6
+ VERSION = "1.0.0.alpha1"
5
7
  end
6
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 1.0.0.alpha1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-18 00:00:00.000000000 Z
11
+ date: 2019-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hanami-utils
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: 2.0.alpha
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.3'
26
+ version: 2.0.alpha
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: concurrent-ruby
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -131,12 +131,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
131
  requirements:
132
132
  - - ">="
133
133
  - !ruby/object:Gem::Version
134
- version: '0'
134
+ version: 2.5.0
135
135
  required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - ">="
137
+ - - ">"
138
138
  - !ruby/object:Gem::Version
139
- version: '0'
139
+ version: 1.3.1
140
140
  requirements: []
141
141
  rubygems_version: 3.0.2
142
142
  signing_key: