From 8fabdf4502d90563ff86929e3f8e08b41a83b335 Mon Sep 17 00:00:00 2001 From: sammyette Date: Tue, 24 Oct 2023 23:59:53 -0400 Subject: [PATCH] fix: correct no files check to compensate for pipes --- nature/commands/greenhouse.lua | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/nature/commands/greenhouse.lua b/nature/commands/greenhouse.lua index 8e0d0e1..0f7971e 100644 --- a/nature/commands/greenhouse.lua +++ b/nature/commands/greenhouse.lua @@ -102,23 +102,23 @@ commander.register('greenhouse', function(args, sinks) gh:addPage(page) end - if #args ~= 0 then - for _, name in ipairs(args) do - local f = io.open(name, 'r') - if not f then - sinks.err:writeln(string.format('could not open file %s', name)) - end - - local page = Page(name, f:read '*a') - gh:addPage(page) + for _, name in ipairs(args) do + local f = io.open(name, 'r') + if not f then + sinks.err:writeln(string.format('could not open file %s', name)) end - ansikit.hideCursor() - gh:initUi() - else + local page = Page(name, f:read '*a') + gh:addPage(page) + end + + if #gh.pages == 0 then sinks.out:writeln [[greenhouse is the Hilbish pager library and command! usage: greenhouse ... example: greenhouse hello.md]] + return 1 end + ansikit.hideCursor() + gh:initUi() end)