Give hint about possibly missing artifacts file when only having a src directory
nfeske opened this issue · 7 comments
If a Goa project only has a src directory but no artifacts file, goa prints the following error:
$ goa build
Error: ... does not look like a goa project
However, in an initial project phase - e.g., while crafting an import file and trying to get some 3rd-party code compiled -
there exists no artifacts file yet because one hasn't got hold of any binaries yet (hence, no clue what to write into the artifacts file). It would be nice of Goa to account for this situation by giving an instructive message whenever a src directory is present but no artifacts file, like:
"The project has a 'src' directory but lacks an 'artifacts' file. You may start with an empty file."
I think that the message should better be printed outside the looks_like_goa_project_dir
function because this function is also used by goa_project_dirs
for finding project candidates when issuing goa -r
. In this case, the directory should simply be rejected as a project without giving any instructive messages.
This is why I added the optional fail_silent
argument. When called from goa_project_dirs
, the directory is rejected without printing any message.
Thanks for pointing this out. I indeed missed the argument. But as a matter of style, wouldn't it be more intuitive to separate the two concerns instead of adding a policy argument? I was thinking of leaving the looks_like_goa_project_dir
as is, but supplementing a function have_src_but_no_artifacts
. This way, both functions just answer a question, and the code that wants to give the hint message would look like:
if {![looks_like_goa_project_dir] && [have_src_but_no_artifacts]} {
error ...
By placing the side effect (printing the message) outside, the code at the caller site expresses the intent a little bit better.
I agree with your style argument. I'll reconsider it.
Thank you! :)