Created
January 16, 2009 12:16
-
-
Save satococoa/47906 to your computer and use it in GitHub Desktop.
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 | |
| # 空のディレクトリの中に空のファイルを作る | |
| # gitなどのお供に | |
| require 'pathname' | |
| if ARGV[0] =~ /-{1,2}h+/ | |
| puts 'example) ruby mkblank.rb -v /path/to/dir filename' | |
| exit | |
| end | |
| def mkblank(path, fname) | |
| if path.children.length == 0 && path.directory? | |
| `touch #{(path + fname).to_s}` | |
| puts path + fname | |
| else | |
| path.children.each do |child| | |
| if child.directory? | |
| mkblank child, fname | |
| end | |
| end | |
| end | |
| end | |
| begin | |
| if ARGV[0] == nil | |
| path = Pathname('.') | |
| elsif !(path = Pathname(ARGV[0])).exist? | |
| raise 'invalid path' | |
| end | |
| if ARGV[1] == nil | |
| fname = '.blank' | |
| else | |
| fname = ARGV[1] | |
| end | |
| mkblank path, fname | |
| rescue Exception => e | |
| puts e | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment