私の実行可能なRubyファイルには、次のものがあります。
#!/usr/bin/env ruby
require 'thor'
include Thor::Actions
class UI < Thor
# def self.source_root
# File.dirname(__FILE__)
# end
desc "makecal", "Generates postscript calendar to your desktop"
def makecal
# puts `ls ~`
puts run('ls ~')
# puts run "pcalmakecal -B -b all -d Helvetica/8 -t Helvetica/16 -S #{Time.now.month} #{Time.now.year} > ~/Desktop/#{Time.now.month}-#{Time.now.year}"
end
end
UI.start
端末でファイルをそのまま実行すると、トールの実行コマンドが NilClass を返すため、空の行が表示されます。
しかし、puts `ls ~` のコメントを外し、Thor の run メソッドをコメント アウトすると、期待どおりにホーム ディレクトリの出力が得られます。
Thor の run メソッドを Ruby の tick のように動作させられない理由がわかりません。
私が間違っていたかもしれないアイデアはありますか?
ご覧いただきありがとうございます