From 4e138f7a2baf0a4565bd82a3757ed5da97f56549 Mon Sep 17 00:00:00 2001 From: Naeem Model Date: Thu, 17 Jul 2025 03:28:45 +0000 Subject: [PATCH] Allow reading files/URIs from STDIN --- lib/App/Fey.pm | 14 ++++++++++++++ script/fey | 2 ++ 2 files changed, 16 insertions(+) diff --git a/lib/App/Fey.pm b/lib/App/Fey.pm index 7b287f0..8b802a0 100644 --- a/lib/App/Fey.pm +++ b/lib/App/Fey.pm @@ -27,6 +27,13 @@ sub launch { my $self = shift; my $options = ref $_[0] ? shift : {}; + if (!(-t STDIN)) { + _read_stdin(\@_); + } + if (!@_ || $options->{interactive}) { + open STDIN, '<', '/dev/tty'; + _read_stdin(\@_); + } die "No files or URIs specified.\n" unless @_; if ($options->{group}) { @@ -129,6 +136,13 @@ sub _get_handler { } } +sub _read_stdin { + for my $file_or_uri () { + chomp $file_or_uri; + push @{ $_[0] }, $file_or_uri; + } +} + sub fey { App::Fey->new(ref $_[0] ? $_[0] : {})->launch(@_); } diff --git a/script/fey b/script/fey index 69eca68..490366d 100644 --- a/script/fey +++ b/script/fey @@ -10,6 +10,7 @@ my $options = { context => undef, fork => 0, group => 0, + interactive => 0, single => 0 }; @@ -17,6 +18,7 @@ GetOptions( 'c|context:s' => \$options->{context}, 'f|fork' => \$options->{fork}, 'g|group' => \$options->{group}, + 'i|interactive' => \$options->{interactive}, 's|single' => \$options->{single} ); -- 2.50.1