-
Notifications
You must be signed in to change notification settings - Fork 17
/
Rakefile
67 lines (52 loc) · 1.86 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
require 'bundler'
Bundler::GemHelper.install_tasks
desc 'Default: Run all tests'
task default: [:rspec, :features]
task :features do
system 'bundle exec cucumber'
end
task :rspec do
system 'bundle exec rspec'
end
task :readme do
require File.expand_path('lib/geordi/cli', __dir__)
readme = File.read('README.md')
geordi_section_regex = /
`geordi`\n
-{3,} # 3 dashes or more
.*? # anything, non-greedy
(?= # stop before:
^\w+\n-{3,} # the next section
)
/xm
geordi_section = <<-TEXT
`geordi`
--------
The `geordi` binary holds most of the utility commands. For the few other
binaries, see the bottom of this file.
You may abbreviate commands by typing only their first letters, e.g. `geordi
con` will boot a development console, `geordi set -t` will setup a project and
run tests afterwards.
Commands will occasionally print "did you know" hints of other Geordi features.
You can always run `geordi help <command>` to quickly look up command help.
TEXT
Geordi::CLI.all_commands.sort.each do |_, command|
next if command.hidden?
geordi_section << "\n### `geordi #{command.usage}`\n"
geordi_section << "#{command.description.sub /(\.)?$/, '.'}\n\n"
geordi_section << "#{command.long_description.strip}\n\n" if command.long_description
visible_options = command.options.reject {|_option_name, option_object| option_object.hide }
if visible_options.any?
geordi_section << "**Options**\n"
visible_options.values.each do |option|
geordi_section << "- `#{option.usage}`"
geordi_section << ": #{option.description}" if option.description
geordi_section << "\n"
end
geordi_section << "\n"
end
end
updated_readme = readme.sub(geordi_section_regex, geordi_section)
File.open('README.md', 'w') { |f| f.puts updated_readme.strip }
puts 'README.md updated.'
end