Skip to content

Commit

Permalink
Init. First available version.
Browse files Browse the repository at this point in the history
  • Loading branch information
nykma committed Jun 12, 2015
1 parent 0ffdbe3 commit eed2766
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 吃什么-专治各种选择障碍

# Prepare

用yml写好一个饭馆列表,格式如下:

```yaml
menu:
燃面
食堂
兰州拉面
川菜馆
全家
```
# Usage
```bash
./chishenme.rb
-m (--menu) : Specify a menu. Default is ~/.menu.yml
```
17 changes: 17 additions & 0 deletions chishenme.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env ruby
# 吃什么-专治各种选择障碍

require "optparse"
require "yaml"

params = ARGV.getopts("", "menu:~/.menu.yml")
config_path = File.expand_path(params["menu"])
begin
menu = YAML.load_file(config_path)
menu = menu["menu"].split
rescue
puts "你丫还没填好菜单吧!" and abort
end

puts "今天去:#{menu[rand(menu.length)]}"
exit

0 comments on commit eed2766

Please sign in to comment.