-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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 | ||
``` |
This file contains 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
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 |