From 0e3fd1ff49416924832b4b3514f95819affaa6b6 Mon Sep 17 00:00:00 2001 From: sammyette Date: Wed, 18 Jan 2023 06:33:15 -0400 Subject: [PATCH] feat: use sinks for doc command --- nature/commands/doc.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/nature/commands/doc.lua b/nature/commands/doc.lua index bc45eea..df9d4c0 100644 --- a/nature/commands/doc.lua +++ b/nature/commands/doc.lua @@ -2,7 +2,7 @@ local commander = require 'commander' local fs = require 'fs' local lunacolors = require 'lunacolors' -commander.register('doc', function(args) +commander.register('doc', function(args, sinks) local moddocPath = hilbish.dataDir .. '/docs/' local apidocHeader = [[ # %s @@ -30,7 +30,7 @@ commander.register('doc', function(args) f = io.open(moddocPath .. subdocName .. '.md', 'rb') end if not f then - print('No documentation found for ' .. mod .. '.') + sinks.out:write('No documentation found for ' .. mod .. '.') return end end @@ -74,7 +74,7 @@ commander.register('doc', function(args) end):gsub('#+.-\n', function(t) return '{bold}{magenta}' .. t .. '{reset}' end)) - print(formattedFuncs) + sinks.out:write(formattedFuncs) f:close() return @@ -83,7 +83,7 @@ commander.register('doc', function(args) return lunacolors.underline(lunacolors.blue(string.gsub(f, '.md', ''))) end) - io.write [[ + sinks.out:write [[ Welcome to Hilbish's doc tool! Here you can find documentation for builtin functions and other things. @@ -91,7 +91,6 @@ Usage: doc
[subdoc] A section is a module or a literal section and a subdoc is a subsection for it. Available sections: ]] - io.flush() - print(table.concat(modules, ', ')) + sinks.out:write(table.concat(modules, ', ') .. '\n') end)