Hanami CLI Build your full featured Ruby CLI in a minute
Hanami CLI
Build your full featured Ruby CLI in a minute
# 1. $ gem install hanami-cli
# 2. $ vim foo
#!/usr/bin/env ruby
require "hanami/cli"
module Foo
module CLI
module Commands
extend Hanami::CLI::Registry
class Hello < Hanami::CLI::Command
argument :name, required: true
def call(name:, **)
puts "Hello, #{name}"
end
end
register "hello", Hello, aliases: ["hi"]
end
end
end
Hanami::CLI.new(Foo::CLI::Commands).call
# 3. $ chmod +x foo
# $ ./foo hello Luca
# Hello, Luca
# $ ./foo hi Luca
# $ ./foo hello
# $ ./foo hello --help
More at: https://github.com/hanami/cli
Twitter Facebook