Do not print error on standard output

Delayed error when passing invalid directory argument.
This commit is contained in:
Francesco Abbate 2021-02-19 09:29:46 +01:00
parent 6fcdafc5b6
commit 114f6b2481
1 changed files with 6 additions and 1 deletions

View File

@ -369,6 +369,7 @@ function core.init()
local project_dir = core.recent_projects[1] or "." local project_dir = core.recent_projects[1] or "."
local project_dir_explicit = false local project_dir_explicit = false
local files = {} local files = {}
local delayed_error
for i = 2, #ARGS do for i = 2, #ARGS do
local arg_filename = strip_trailing_slash(ARGS[i]) local arg_filename = strip_trailing_slash(ARGS[i])
local info = system.get_file_info(arg_filename) or {} local info = system.get_file_info(arg_filename) or {}
@ -382,7 +383,7 @@ function core.init()
project_dir = arg_filename project_dir = arg_filename
project_dir_explicit = true project_dir_explicit = true
else else
print(string.format("error: invalid file or directory %q", ARGS[i])) delayed_error = string.format("error: invalid file or directory %q", ARGS[i])
end end
end end
@ -437,6 +438,10 @@ function core.init()
core.root_view:open_doc(core.open_doc(filename)) core.root_view:open_doc(core.open_doc(filename))
end end
if delayed_error then
core.error(delayed_error)
end
if got_plugin_error or got_user_error or got_project_error then if got_plugin_error or got_user_error or got_project_error then
command.perform("core:open-log") command.perform("core:open-log")
end end