I'm creating a gem that gives the weather connecting to APIs, i also created tests and class methods, now i want to add a command line interpreter (CLI).
As the bundler site tutorial for create gem, i'm trying to do it with Thor
/bin/wizer
file#!/usr/bin/env bash
require "wizer/cli"
Wizer::CLI.start
/lib/wizer/cli.rb
require 'thor'
require 'wizer'
module Wizer
class CLI < Thor
desc "hello world", "my first cli"
def self.hello
"Hello world"
end
end
end
wizer.gemspec
file spec.add_runtime_dependency "thor"
Gemfile
gem "thor"
See full gem here
答案 0 :(得分:1)
这里的主要问题是Ruby不解释getServices
文件。而是使用了Bash,它无法处理Ruby代码(或其他任何不像Bourne的shell脚本)。
要解决此问题,请将shebang行(即以bin/wizer
开头的文件中的第一行)更改为以下内容:
#!