Skip to content

Commit d5eb9c9

Browse files
committed
Codegen .config/readmer/*.sh-session.
1 parent 4e6783f commit d5eb9c9

10 files changed

Lines changed: 28 additions & 6 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ asimov ask --help
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ asimov fetch --help
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ asimov handle --help
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ asimov list --help
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ asimov module --help
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ asimov read --help
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ asimov snap --help
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ asimov snapshot --help

.config/readmer/asimov.sh-session

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ asimov

Rakefile

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1-
namespace :version do
2-
desc "Bump the version number"
3-
task :bump do
4-
old_version = File.read('VERSION').strip
5-
new_version = old_version.gsub(/\.\d+$/, &:succ)
6-
warn `git grep -l #{old_version} | xargs sd -F #{old_version} #{new_version}`.chomp
1+
abort("Expected Ruby 3.4+, but got #{RUBY_VERSION}.") if RUBY_VERSION < '3.4.0'
2+
3+
ASIMOV_SUBCOMMANDS = %w[ask fetch handle list module read snap snapshot]
4+
5+
task default: %w[codegen]
6+
7+
desc "Generate .config/readmer/*.sh-session files"
8+
task codegen: %w[.config/readmer/asimov.sh-session] +
9+
ASIMOV_SUBCOMMANDS.map { ".config/readmer/asimov-#{it}.sh-session" }.to_a
10+
11+
([nil] + ASIMOV_SUBCOMMANDS).each do |subcommand|
12+
command = subcommand ? "asimov #{subcommand} --help" : "asimov"
13+
filename = command.delete_suffix(' --help').gsub(' ', '-')
14+
desc "Generate .config/readmer/#{filename}.sh-session"
15+
file ".config/readmer/#{filename}.sh-session" do |t|
16+
File.open(t.name, 'w') do |f|
17+
f.puts "$ #{command}"
18+
#f.puts `#{command} 2>&1` # FIXME
19+
end
720
end
821
end

0 commit comments

Comments
 (0)