hanami-cli 2.0.0.rc1 → 2.0.0

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.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -0
  3. data/.yardopts +3 -0
  4. data/CHANGELOG.md +12 -0
  5. data/Gemfile +3 -4
  6. data/exe/hanami +6 -1
  7. data/hanami-cli.gemspec +3 -2
  8. data/lib/hanami/cli/bundler.rb +95 -5
  9. data/lib/hanami/cli/command.rb +41 -0
  10. data/lib/hanami/cli/commands/app/command.rb +63 -2
  11. data/lib/hanami/cli/commands/app/console.rb +7 -3
  12. data/lib/hanami/cli/commands/app/db/create.rb +2 -0
  13. data/lib/hanami/cli/commands/app/db/create_migration.rb +3 -0
  14. data/lib/hanami/cli/commands/app/db/drop.rb +2 -0
  15. data/lib/hanami/cli/commands/app/db/migrate.rb +2 -0
  16. data/lib/hanami/cli/commands/app/db/reset.rb +2 -0
  17. data/lib/hanami/cli/commands/app/db/rollback.rb +2 -0
  18. data/lib/hanami/cli/commands/app/db/sample_data.rb +2 -0
  19. data/lib/hanami/cli/commands/app/db/seed.rb +2 -0
  20. data/lib/hanami/cli/commands/app/db/setup.rb +2 -0
  21. data/lib/hanami/cli/commands/app/db/structure/dump.rb +3 -0
  22. data/lib/hanami/cli/commands/app/db/utils/database.rb +155 -0
  23. data/lib/hanami/cli/commands/app/db/utils/database_config.rb +60 -0
  24. data/lib/hanami/cli/commands/app/db/utils/mysql.rb +33 -0
  25. data/lib/hanami/cli/commands/app/db/utils/postgres.rb +64 -0
  26. data/lib/hanami/cli/commands/app/db/utils/sqlite.rb +45 -0
  27. data/lib/hanami/cli/commands/app/db/version.rb +2 -0
  28. data/lib/hanami/cli/commands/app/generate/action.rb +10 -3
  29. data/lib/hanami/cli/commands/app/generate/slice.rb +9 -6
  30. data/lib/hanami/cli/commands/app/generate.rb +2 -0
  31. data/lib/hanami/cli/commands/app/install.rb +13 -2
  32. data/lib/hanami/cli/commands/app/middleware.rb +7 -1
  33. data/lib/hanami/cli/commands/app/routes.rb +8 -0
  34. data/lib/hanami/cli/commands/app/server.rb +10 -0
  35. data/lib/hanami/cli/commands/app/version.rb +4 -2
  36. data/lib/hanami/cli/commands/app.rb +6 -19
  37. data/lib/hanami/cli/commands/gem/new.rb +12 -13
  38. data/lib/hanami/cli/commands/gem/version.rb +4 -2
  39. data/lib/hanami/cli/commands/gem.rb +8 -5
  40. data/lib/hanami/cli/commands.rb +19 -3
  41. data/lib/hanami/cli/errors.rb +65 -0
  42. data/lib/hanami/cli/files.rb +10 -0
  43. data/lib/hanami/cli/generators/app/action.rb +11 -5
  44. data/lib/hanami/cli/generators/app/action_context.rb +22 -0
  45. data/lib/hanami/cli/generators/app/slice.rb +6 -1
  46. data/lib/hanami/cli/generators/app/slice_context.rb +8 -0
  47. data/lib/hanami/cli/generators/context.rb +14 -0
  48. data/lib/hanami/cli/generators/gem/app.rb +9 -5
  49. data/lib/hanami/cli/generators/version.rb +8 -6
  50. data/lib/hanami/cli/middleware_stack_inspector.rb +5 -0
  51. data/lib/hanami/cli/rake_tasks.rb +0 -1
  52. data/lib/hanami/cli/repl/core.rb +12 -4
  53. data/lib/hanami/cli/repl/irb.rb +3 -2
  54. data/lib/hanami/cli/repl/pry.rb +1 -3
  55. data/lib/hanami/cli/server.rb +11 -0
  56. data/lib/hanami/cli/system_call.rb +65 -7
  57. data/lib/hanami/cli/url.rb +9 -2
  58. data/lib/hanami/cli/version.rb +4 -1
  59. data/lib/hanami/cli.rb +26 -3
  60. data/lib/hanami/console/context.rb +4 -2
  61. data/lib/hanami/console/plugins/slice_readers.rb +1 -0
  62. data/lib/hanami-cli.rb +3 -0
  63. metadata +46 -25
  64. data/lib/hanami/cli/command_line.rb +0 -17
  65. data/lib/hanami/cli/commands/db/utils/database.rb +0 -133
  66. data/lib/hanami/cli/commands/db/utils/database_config.rb +0 -48
  67. data/lib/hanami/cli/commands/db/utils/mysql.rb +0 -27
  68. data/lib/hanami/cli/commands/db/utils/postgres.rb +0 -54
  69. data/lib/hanami/cli/commands/db/utils/sqlite.rb +0 -37
  70. data/lib/hanami/cli/error.rb +0 -8
@@ -1,16 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "hanami/cli/command"
4
- require "hanami/cli/bundler"
5
- require "hanami/cli/command_line"
6
- require "hanami/cli/generators/gem/app"
7
- require "hanami/cli/files"
8
3
  require "dry/inflector"
4
+ require_relative "../../errors"
9
5
 
10
6
  module Hanami
11
7
  module CLI
12
8
  module Commands
13
9
  module Gem
10
+ # @since 2.0.0
11
+ # @api private
14
12
  class New < Command
15
13
  SKIP_INSTALL_DEFAULT = false
16
14
  private_constant :SKIP_INSTALL_DEFAULT
@@ -28,25 +26,27 @@ module Hanami
28
26
  "bookshelf --skip-install # Generate a new Hanami app, but it skips Hanami installation"
29
27
  ]
30
28
 
31
- # rubocop:disable Metrics/ParameterLists
29
+ # @since 2.0.0
30
+ # @api private
32
31
  def initialize(
33
32
  fs: Hanami::CLI::Files.new,
34
33
  inflector: Dry::Inflector.new,
35
34
  bundler: CLI::Bundler.new(fs: fs),
36
- command_line: CLI::CommandLine.new(bundler: bundler),
37
- generator: Generators::Gem::App.new(fs: fs, inflector: inflector, command_line: command_line),
35
+ generator: Generators::Gem::App.new(fs: fs, inflector: inflector),
38
36
  **other
39
37
  )
40
38
  @bundler = bundler
41
- @command_line = command_line
42
39
  @generator = generator
43
40
  super(fs: fs, inflector: inflector, **other)
44
41
  end
45
- # rubocop:enable Metrics/ParameterLists
46
42
 
43
+ # @since 2.0.0
44
+ # @api private
47
45
  def call(app:, skip_install: SKIP_INSTALL_DEFAULT, **)
48
46
  app = inflector.underscore(app)
49
47
 
48
+ raise PathAlreadyExistsError.new(app) if fs.exist?(app)
49
+
50
50
  fs.mkdir(app)
51
51
  fs.chdir(app) do
52
52
  generator.call(app) do
@@ -65,12 +65,11 @@ module Hanami
65
65
  private
66
66
 
67
67
  attr_reader :bundler
68
- attr_reader :command_line
69
68
  attr_reader :generator
70
69
 
71
70
  def run_install_commmand!
72
- command_line.call("hanami install").tap do |result|
73
- raise "hanami install failed\n\n\n#{result.err.inspect}" unless result.successful?
71
+ bundler.exec("hanami install").tap do |result|
72
+ raise HanamiInstallError.new(result.err) unless result.successful?
74
73
  end
75
74
  end
76
75
  end
@@ -1,14 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "hanami/cli/command"
4
-
5
3
  module Hanami
6
4
  module CLI
7
5
  module Commands
8
6
  module Gem
7
+ # @since 2.0.0
8
+ # @api private
9
9
  class Version < Command
10
10
  desc "Hanami version"
11
11
 
12
+ # @since 2.0.0
13
+ # @api private
12
14
  def call(*)
13
15
  version = detect_version
14
16
  out.puts "v#{version}"
@@ -3,14 +3,17 @@
3
3
  module Hanami
4
4
  module CLI
5
5
  module Commands
6
+ # Commands made available when the `hanami` CLI is executed outside of an Hanami app.
7
+ #
8
+ # @since 2.0.0
9
+ # @api public
6
10
  module Gem
7
- require_relative "gem/version"
8
- require_relative "gem/new"
9
-
11
+ # @since 2.0.0
12
+ # @api private
10
13
  def self.extended(base)
11
14
  base.module_eval do
12
- register "version", Version, aliases: ["v", "-v", "--version"]
13
- register "new", New
15
+ register "version", Commands::Gem::Version, aliases: ["v", "-v", "--version"]
16
+ register "new", Commands::Gem::New
14
17
  end
15
18
  end
16
19
  end
@@ -7,13 +7,29 @@ module Hanami
7
7
  # This is typically used to determine whether to register commands that are applicable either
8
8
  # inside or outside an app.
9
9
  #
10
- # @api public
10
+ # @return [Boolean]
11
+ #
12
+ # @api private
11
13
  # @since 2.0.0
12
14
  def self.within_hanami_app?
13
- File.exist?("config/app.rb") ||
14
- File.exist?("app.rb")
15
+ require "hanami"
16
+
17
+ !!Hanami.app_path
18
+ rescue LoadError => e
19
+ raise e unless e.path == "hanami"
20
+
21
+ # If for any reason the hanami gem isn't installed, make a simple best effort to determine
22
+ # whether we're inside an app.
23
+ File.exist?("config/app.rb") || File.exist?("app.rb")
15
24
  end
16
25
 
26
+ # Contains the commands available for the current `hanami` CLI execution, depending on whether
27
+ # the CLI is executed inside or outside an Hanami app.
28
+ #
29
+ # @see .within_hanami_app?
30
+ #
31
+ # @api public
32
+ # @since 2.0.0
17
33
  module Commands
18
34
  end
19
35
 
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hanami
4
+ module CLI
5
+ class Error < StandardError
6
+ end
7
+
8
+ class NotImplementedError < Error
9
+ end
10
+
11
+ class BundleInstallError < Error
12
+ def initialize(message)
13
+ super("`bundle install' failed\n\n\n#{message.inspect}")
14
+ end
15
+ end
16
+
17
+ class HanamiInstallError < Error
18
+ def initialize(message)
19
+ super("`hanami install' failed\n\n\n#{message.inspect}")
20
+ end
21
+ end
22
+
23
+ class PathAlreadyExistsError < Error
24
+ def initialize(path)
25
+ super("Cannot create new Hanami app in an existing path: `#{path}'")
26
+ end
27
+ end
28
+
29
+ class MissingSliceError < Error
30
+ def initialize(slice)
31
+ super("slice `#{slice}' is missing, please generate with `hanami generate slice #{slice}'")
32
+ end
33
+ end
34
+
35
+ class InvalidURLError < Error
36
+ def initialize(url)
37
+ super("invalid URL: `#{url}'")
38
+ end
39
+ end
40
+
41
+ class InvalidURLPrefixError < Error
42
+ def initialize(url)
43
+ super("invalid URL prefix: `#{url}'")
44
+ end
45
+ end
46
+
47
+ class InvalidActionNameError < Error
48
+ def initialize(name)
49
+ super("cannot parse controller and action name: `#{name}'\n\texample: `hanami generate action users.show'")
50
+ end
51
+ end
52
+
53
+ class UnknownHTTPMethodError < Error
54
+ def initialize(name)
55
+ super("unknown HTTP method: `#{name}'")
56
+ end
57
+ end
58
+
59
+ class UnsupportedDatabaseSchemeError < Error
60
+ def initialize(scheme)
61
+ super("`#{scheme}' is not a supported db scheme")
62
+ end
63
+ end
64
+ end
65
+ end
@@ -2,12 +2,18 @@
2
2
 
3
3
  module Hanami
4
4
  module CLI
5
+ # @since 2.0.0
6
+ # @api private
5
7
  class Files < Dry::Files
8
+ # @since 2.0.0
9
+ # @api private
6
10
  def initialize(out: $stdout, **args)
7
11
  super(**args)
8
12
  @out = out
9
13
  end
10
14
 
15
+ # @since 2.0.0
16
+ # @api private
11
17
  def write(path, *content)
12
18
  already_exists = exist?(path)
13
19
  super
@@ -18,6 +24,8 @@ module Hanami
18
24
  end
19
25
  end
20
26
 
27
+ # @since 2.0.0
28
+ # @api private
21
29
  def mkdir(path)
22
30
  unless exist?(path)
23
31
  super
@@ -25,6 +33,8 @@ module Hanami
25
33
  end
26
34
  end
27
35
 
36
+ # @since 2.0.0
37
+ # @api private
28
38
  def chdir(path, &blk)
29
39
  within_folder(path)
30
40
  super
@@ -2,22 +2,27 @@
2
2
 
3
3
  require "erb"
4
4
  require "dry/files"
5
- require "hanami/cli/files"
6
- require "hanami/cli/generators/app/action_context"
7
- require "hanami/cli/url"
5
+ require_relative "../../errors"
8
6
 
9
7
  # rubocop:disable Metrics/ParameterLists
10
8
  module Hanami
11
9
  module CLI
12
10
  module Generators
13
11
  module App
12
+ # @since 2.0.0
13
+ # @api private
14
14
  class Action
15
+ # @since 2.0.0
16
+ # @api private
15
17
  def initialize(fs:, inflector:)
16
18
  @fs = fs
17
19
  @inflector = inflector
18
20
  end
19
21
 
20
22
  # rubocop:disable Layout/LineLength
23
+
24
+ # @since 2.0.0
25
+ # @api private
21
26
  def call(app, controller, action, url, http, format, skip_view, slice, context: ActionContext.new(inflector, app, slice, controller, action))
22
27
  if slice
23
28
  generate_for_slice(controller, action, url, http, format, skip_view, slice, context)
@@ -25,6 +30,7 @@ module Hanami
25
30
  generate_for_app(controller, action, url, http, format, skip_view, context)
26
31
  end
27
32
  end
33
+
28
34
  # rubocop:enable Layout/LineLength
29
35
 
30
36
  private
@@ -62,7 +68,7 @@ module Hanami
62
68
 
63
69
  def generate_for_slice(controller, action, url, http, _format, _skip_view, slice, context)
64
70
  slice_directory = fs.join("slices", slice)
65
- raise ArgumentError.new("slice not found `#{slice}'") unless fs.directory?(slice_directory)
71
+ raise MissingSliceError.new(slice) unless fs.directory?(slice_directory)
66
72
 
67
73
  fs.inject_line_at_block_bottom(
68
74
  fs.join("config", "routes.rb"),
@@ -132,7 +138,7 @@ module Hanami
132
138
  result = (http ||= ROUTE_RESTFUL_HTTP_METHODS.fetch(action, ROUTE_DEFAULT_HTTP_METHOD)).downcase
133
139
 
134
140
  unless ROUTE_HTTP_METHODS.include?(result)
135
- raise ArgumentError.new("unknown HTTP method: `#{http}'")
141
+ raise UnknownHTTPMethodError.new(http)
136
142
  end
137
143
 
138
144
  result
@@ -6,50 +6,72 @@ require "dry/files/path"
6
6
  module Hanami
7
7
  module CLI
8
8
  module Generators
9
+ # @since 2.0.0
10
+ # @api private
9
11
  module App
12
+ # @since 2.0.0
13
+ # @api private
10
14
  class ActionContext < SliceContext
15
+ # @since 2.0.0
16
+ # @api private
11
17
  def initialize(inflector, app, slice, controller, action)
12
18
  @controller = controller
13
19
  @action = action
14
20
  super(inflector, app, slice, nil)
15
21
  end
16
22
 
23
+ # @since 2.0.0
24
+ # @api private
17
25
  def camelized_controller_name
18
26
  controller.map do |token|
19
27
  inflector.camelize(token)
20
28
  end.join(NAMESPACE_SEPARATOR)
21
29
  end
22
30
 
31
+ # @since 2.0.0
32
+ # @api private
23
33
  def camelized_action_name
24
34
  inflector.camelize(action)
25
35
  end
26
36
 
37
+ # @since 2.0.0
38
+ # @api private
27
39
  def underscored_controller_name
28
40
  controller.map do |token|
29
41
  inflector.underscore(token)
30
42
  end
31
43
  end
32
44
 
45
+ # @since 2.0.0
46
+ # @api private
33
47
  def underscored_action_name
34
48
  inflector.underscore(action)
35
49
  end
36
50
 
51
+ # @since 2.0.0
52
+ # @api private
37
53
  def module_controller_declaration
38
54
  controller.each_with_index.map do |token, i|
39
55
  "#{OFFSET}#{INDENTATION * i}module #{inflector.camelize(token)}"
40
56
  end.join($/)
41
57
  end
42
58
 
59
+ # @since 2.0.0
60
+ # @api private
43
61
  def module_controller_end
44
62
  controller.each_with_index.map do |_, i|
45
63
  "#{OFFSET}#{INDENTATION * i}end"
46
64
  end.reverse.join($/)
47
65
  end
48
66
 
67
+ # @since 2.0.0
68
+ # @api private
49
69
  def module_controller_offset
50
70
  "#{OFFSET}#{INDENTATION * controller.count}"
51
71
  end
52
72
 
73
+ # @since 2.0.0
74
+ # @api private
53
75
  def template_path
54
76
  Dry::Files::Path["slices", underscored_slice_name, "templates", *underscored_controller_name,
55
77
  "#{underscored_action_name}.html.erb"]
@@ -2,18 +2,23 @@
2
2
 
3
3
  require "erb"
4
4
  require "dry/files"
5
- require "hanami/cli/generators/app/slice_context"
6
5
 
7
6
  module Hanami
8
7
  module CLI
9
8
  module Generators
10
9
  module App
10
+ # @since 2.0.0
11
+ # @api private
11
12
  class Slice
13
+ # @since 2.0.0
14
+ # @api private
12
15
  def initialize(fs:, inflector:)
13
16
  @fs = fs
14
17
  @inflector = inflector
15
18
  end
16
19
 
20
+ # @since 2.0.0
21
+ # @api private
17
22
  def call(app, slice, url, context: SliceContext.new(inflector, app, slice, url))
18
23
  fs.inject_line_at_class_bottom(
19
24
  fs.join("config", "routes.rb"), "class Routes", t("routes.erb", context).chomp
@@ -6,17 +6,25 @@ module Hanami
6
6
  module CLI
7
7
  module Generators
8
8
  module App
9
+ # @since 2.0.0
10
+ # @api private
9
11
  class SliceContext < Generators::Context
12
+ # @since 2.0.0
13
+ # @api private
10
14
  def initialize(inflector, app, slice, url)
11
15
  @slice = slice
12
16
  @url = url
13
17
  super(inflector, app)
14
18
  end
15
19
 
20
+ # @since 2.0.0
21
+ # @api private
16
22
  def camelized_slice_name
17
23
  inflector.camelize(slice)
18
24
  end
19
25
 
26
+ # @since 2.0.0
27
+ # @api private
20
28
  def underscored_slice_name
21
29
  inflector.underscore(slice)
22
30
  end
@@ -4,25 +4,39 @@ require_relative "./version"
4
4
 
5
5
  module Hanami
6
6
  module CLI
7
+ # @since 2.0.0
8
+ # @api private
7
9
  module Generators
10
+ # @since 2.0.0
11
+ # @api private
8
12
  class Context
13
+ # @since 2.0.0
14
+ # @api private
9
15
  def initialize(inflector, app)
10
16
  @inflector = inflector
11
17
  @app = app
12
18
  end
13
19
 
20
+ # @since 2.0.0
21
+ # @api private
14
22
  def ctx
15
23
  binding
16
24
  end
17
25
 
26
+ # @since 2.0.0
27
+ # @api private
18
28
  def hanami_version
19
29
  Version.gem_requirement
20
30
  end
21
31
 
32
+ # @since 2.0.0
33
+ # @api private
22
34
  def camelized_app_name
23
35
  inflector.camelize(app)
24
36
  end
25
37
 
38
+ # @since 2.0.0
39
+ # @api private
26
40
  def underscored_app_name
27
41
  inflector.underscore(app)
28
42
  end
@@ -2,20 +2,26 @@
2
2
 
3
3
  require "erb"
4
4
  require "shellwords"
5
- require "hanami/cli/generators/context"
6
5
 
7
6
  module Hanami
8
7
  module CLI
9
8
  module Generators
9
+ # @since 2.0.0
10
+ # @api private
10
11
  module Gem
12
+ # @since 2.0.0
13
+ # @api private
11
14
  class App
12
- def initialize(fs:, inflector:, command_line:)
15
+ # @since 2.0.0
16
+ # @api private
17
+ def initialize(fs:, inflector:)
13
18
  super()
14
19
  @fs = fs
15
20
  @inflector = inflector
16
- @command_line = command_line
17
21
  end
18
22
 
23
+ # @since 2.0.0
24
+ # @api private
19
25
  def call(app, context: Context.new(inflector, app), &blk)
20
26
  generate_app(app, context)
21
27
  blk.call
@@ -27,8 +33,6 @@ module Hanami
27
33
 
28
34
  attr_reader :inflector
29
35
 
30
- attr_reader :command_line
31
-
32
36
  def generate_app(app, context) # rubocop:disable Metrics/AbcSize
33
37
  fs.write(".env", t("env.erb", context))
34
38
 
@@ -3,6 +3,8 @@
3
3
  module Hanami
4
4
  module CLI
5
5
  module Generators
6
+ # @since 2.0.0
7
+ # @api private
6
8
  module Version
7
9
  # @since 2.0.0
8
10
  # @api private
@@ -30,22 +32,22 @@ module Hanami
30
32
  version =~ /alpha|beta|rc/
31
33
  end
32
34
 
33
- # @since 2.0.0
34
- # @api private
35
- #
36
35
  # @example
37
36
  # Hanami::VERSION # => 2.0.0
38
37
  # Hanami::CLI::Generators::Version.stable_version # => "2.0"
38
+ #
39
+ # @since 2.0.0
40
+ # @api private
39
41
  def self.stable_version
40
42
  version.scan(/\A\d{1,2}\.\d{1,2}/).first
41
43
  end
42
44
 
43
- # @since 2.0.0
44
- # @api private
45
- #
46
45
  # @example
47
46
  # Hanami::VERSION # => 2.0.0.alpha8.1
48
47
  # Hanami::CLI::Generators::Version.stable_version # => "2.0.0.alpha"
48
+ #
49
+ # @since 2.0.0
50
+ # @api private
49
51
  def self.prerelease_version
50
52
  version.sub(/[[[:digit:]].]*\Z/, "")
51
53
  end
@@ -2,12 +2,17 @@
2
2
 
3
3
  module Hanami
4
4
  module CLI
5
+ # @since 2.0.0
5
6
  # @api private
6
7
  class MiddlewareStackInspector
8
+ # @since 2.0.0
9
+ # @api private
7
10
  def initialize(stack:)
8
11
  @stack = stack
9
12
  end
10
13
 
14
+ # @since 2.0.0
15
+ # @api private
11
16
  def inspect(include_arguments: false)
12
17
  max_path_length = @stack.map { |(path)| path.length }.max
13
18
 
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rake"
4
- require "hanami/cli/bundler"
5
4
 
6
5
  module Hanami
7
6
  module CLI
@@ -1,50 +1,58 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "hanami/console/context"
4
+ require_relative "../errors"
4
5
 
5
6
  module Hanami
6
7
  module CLI
8
+ # @since 2.0.0
9
+ # @api private
7
10
  module Repl
11
+ # @since 2.0.0
8
12
  # @api private
9
13
  class Core
10
- # @api private
11
14
  attr_reader :app
12
-
13
- # @api private
14
15
  attr_reader :opts
15
16
 
17
+ # @since 2.0.0
16
18
  # @api private
17
19
  def initialize(app, opts)
18
20
  @app = app
19
21
  @opts = opts
20
22
  end
21
23
 
24
+ # @since 2.0.0
22
25
  # @api private
23
26
  def start
24
- raise NotImplementedError
27
+ raise Hanami::CLI::NotImplementedError
25
28
  end
26
29
 
30
+ # @since 2.0.0
27
31
  # @api private
28
32
  def context
29
33
  @context ||= Hanami::Console::Context.new(app)
30
34
  end
31
35
 
36
+ # @since 2.0.0
32
37
  # @api private
33
38
  def prompt
34
39
  "#{name}[#{env}]"
35
40
  end
36
41
 
42
+ # @since 2.0.0
37
43
  # @api private
38
44
  def name
39
45
  (app.container.config.name || inflector.underscore(app.name))
40
46
  .to_s.split("/")[0]
41
47
  end
42
48
 
49
+ # @since 2.0.0
43
50
  # @api private
44
51
  def env
45
52
  app.container.env
46
53
  end
47
54
 
55
+ # @since 2.0.0
48
56
  # @api private
49
57
  def inflector
50
58
  app.inflector
@@ -7,9 +7,10 @@ module Hanami
7
7
  module CLI
8
8
  module Repl
9
9
  # @since 2.0.0
10
- # @api public
10
+ # @api private
11
11
  class Irb < Core
12
- # @api public
12
+ # @since 2.0.0
13
+ # @api private
13
14
  def start
14
15
  $stdout.sync = true
15
16
 
@@ -7,13 +7,11 @@ module Hanami
7
7
  module CLI
8
8
  module Repl
9
9
  # @since 2.0.0
10
- # @api public
10
+ # @api private
11
11
  class Pry < Core
12
- # @api private
13
12
  class Context
14
13
  end
15
14
 
16
- # @api public
17
15
  def start
18
16
  ::Pry.config.prompt = ::Pry::Prompt.new(
19
17
  "hanami",