-
-
Save ikemo3/c8f756fa0b35eef6c5369e20ca0a3223 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 = 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 |
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