Skip to content

Instantly share code, notes, and snippets.

@ikemo3
Forked from hyuki0000/check.rb
Last active February 28, 2017 09:56
Show Gist options
  • Save ikemo3/c8f756fa0b35eef6c5369e20ca0a3223 to your computer and use it in GitHub Desktop.
Save ikemo3/c8f756fa0b35eef6c5369e20ca0a3223 to your computer and use it in GitHub Desktop.
何か行動するときのチェックリストをチェックする簡単なRubyスクリプト
#!/usr/bin/env ruby
DIRECTORY = ENV['HOME'] + '/.check'
def check(file)
File::open(file) do |f|
f.each_line do |line|
# ignore blank line
next if line =~ /^\n/
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
Dir.chdir(DIRECTORY)
list = Dir.glob("*")
if number and number < list.size
check(list[number])
else
list.each_with_index do |name, index|
first_line = open(name).first
match_data = first_line.match('^# (.*)')
if match_data
puts "#{index}: #{match_data[1]}"
else
puts "#{index}: #{name}"
end
end
end
end
main
原稿ファイルをメール添付で送る場合のチェックリスト
バックアップする。
ファイルを添付する。
送信アドレスをチェックする。
感謝しつつ、送信。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment