Override Hanami Executable

Hi guys!

I’m playing with building a gem that is extension to hanami-cli. Basically, adds bulma support for template generators. When you’ll type: hanami g view whatever, or hanami g slice, it’ll return pre-built bulma templates.

I want to override the executable hanami command, when installed in Gemfile, the command does not seem to e recognised.

Here is the gem draft:

https://github.com/swilgosz/hanami-bulma_cli

I do have exe/hanami executable, and I do have the necessary executables in the *gemspec file.

  spec.files = Dir.chdir(File.expand_path(__dir__)) do
    `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
  end

  spec.bindir = "exe"
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }

What did I overlook?

Solved

The issue was, that I’ve done everything correctly in the gem itself, but I’ve installed via Gemfile (bundler), while running the command without bundle exec

1 Like

Hey @swilgosz! I’m glad you sorted out your original problem, but I think you don’t need to override the hanami executable at all. This leads to confusing warning messages every time someone executes hanami, which isn’t a great experience for our users.

Fortunately, there are more straightforward ways to register commands onto the Hanami CLI. I filed an issue about it here: Register commands with `Hanami::CLI` instead of duplicating the `hanami` executable · Issue #1 · swilgosz/hanami-cli_bulma · GitHub

1 Like