diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-14 09:56:52 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-14 09:56:52 +0200 |
| commit | 818ed50e2a54b40ccf7a7771bebe0312dc01a8b5 (patch) | |
| tree | 16bfb301c1192a1d301d50388eb33a52ecdc7e69 /test/support/mock_agent.rb | |
| parent | 63607f415c45a8670cd2eb4d346e448dceb5422f (diff) | |
Add agent-backed file processing DSL
Diffstat (limited to 'test/support/mock_agent.rb')
| -rw-r--r-- | test/support/mock_agent.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/support/mock_agent.rb b/test/support/mock_agent.rb new file mode 100644 index 0000000..b86de4f --- /dev/null +++ b/test/support/mock_agent.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +mode = ARGV.shift.to_s +stdin = $stdin.read + +case mode +when 'upcase_prompt' + prompt = ARGV.fetch(0, '') + print "#{stdin.upcase}|#{prompt}" +when 'reverse_input' + input_path = ARGV.fetch(0) + print File.read(input_path).reverse +when 'basename' + file_path = ARGV.fetch(0) + print File.basename(file_path) +when 'pass_through' + print stdin +when 'upcase' + print stdin.upcase +when 'fail' + warn ARGV.fetch(0, 'boom') + exit Integer(ARGV.fetch(1, '7')) +else + warn "unknown mode: #{mode}" + exit 2 +end |
