Last active
February 28, 2017 07:41
-
-
Save hyuki0000/4388f83c38d56945dc6c58611560c7c4 to your computer and use it in GitHub Desktop.
何か行動するときのチェックリストをチェックする簡単なRubyスクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
DIRECTORY = '/Users/USERNAME/.check' | |
def check(file) | |
File::open(file) do |f| | |
f.each_line do |line| | |
puts line | |
STDIN.gets.chomp | |
end | |
end | |
end | |
def main | |
if ARGV.length != 0 and ARGV.length != 1 | |
puts "Usage (1): check" | |
puts "Usage (2): check number" | |
abort | |
end | |
number = ARGV[0].to_i if ARGV.length == 1 | |
list = `ls #{DIRECTORY}`.split(/\n/) | |
if number and number < list.size | |
check("#{DIRECTORY}/#{list[number]}") | |
else | |
list.each_with_index do |name, index| | |
puts "#{index}: #{name.sub(/#{DIRECTORY}\//, '')}" | |
end | |
end | |
end | |
main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
原稿ファイルをメール添付で送る場合のチェックリスト | |
バックアップする。 | |
ファイルを添付する。 | |
送信アドレスをチェックする。 | |
感謝しつつ、送信。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
~/.check/ ディレクトリにいくつかのテキストファイルを置いておきます。
一つの「テキストファイル」は一つの「チェックリスト」に対応します。
そして、それぞれのテキストファイルの「一行」は「チェック項目一個」に対応します。
ruby check.rb を実行すると、~/.check/ のファイル一覧を番号付きで表示します。
ruby check.rb 番号 を実行すると指定した番号のファイルを一行ずつ表示し、Enterキー待ちに入ります。