piotrmurach/tty

View on GitHub
lib/tty/templates/new/exe/newcli.tt

Summary

Maintainability
Test Coverage
#!/usr/bin/env <%= RbConfig::CONFIG["ruby_install_name"] %>
# frozen_string_literal: true

lib_path = File.expand_path('../lib', __dir__)
$:.unshift(lib_path) if !$:.include?(lib_path)
require '<%= namespaced_path %>/cli'

Signal.trap('INT') do
  warn("\n#{caller.join("\n")}: interrupted")
  exit(1)
end

begin
  <%= constantinized_name %>::CLI.start
rescue <%= constantinized_name %>::CLI::Error => err
  puts "ERROR: #{err.message}"
  exit 1
end