LoginSignup
1
0

More than 3 years have passed since last update.

第十三回講義メモ

Last updated at Posted at 2020-12-31

!Mac OS X-10.15.7 !ruby-2.6.3p62

thor

いくつかの振る舞いを一つのコマンドに持たそうとすると,オプションなどを適切に扱う必要が出てくる.そのためにいくつかのCLI builder gemsがある.これはRakefileに似たDSLで実現できる.

まずは,

gem install thor

次に以前作ったhello_rubyにcliのinterfaceを組み込む.

require 'thor'
require "hello_rudy/version"

class HelloRudyCLI < Thor
  desc "hello NAME", "say hello to NAME"
  def hello(name)
    puts "Hello " + name
  end
end

HelloRudyCLI.start(ARGV)

CLIという文字列がclass名の最後にないと動かない.

rubocop紹介

これはcode formatterとかlinterと呼ばれる類のツールらしく, 規約通りにコードが書かれているかをチェックしてくれる便利ツール.

gem install rubocop
rubocop --auto-correct fibonacci.rb

参考サイト


  • source ~/my_ruby/grad_members_20f/members/drop-sd/lectures/no13.org
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0