githubnemo / CompileDaemon

Very simple compile daemon for Go
BSD 2-Clause "Simplified" License
1.61k stars 153 forks source link

allow multiple commands to run on build #64

Closed nikolaigut closed 3 years ago

nikolaigut commented 3 years ago

Currently, it is not possible to run multiple commands with the flag --build.

With this change, it is possible to run multiple commands defined in the --build flag.

The commands must be separated by a double ampersand (&&).

For example, CompileDaemon --build="go mod vendor && go build".

This change should fix #52 .

githubnemo commented 3 years ago

Hi, thanks for the contribution!

I think it is bad practice to suggest the presence of a well-known feature when it is, in fact, not that feature - in this case command chaining as implemented by *sh.

I think I would rather have multiple --build arguments for multiple commands than add complexity in the form of string parsing (and escaping of special character sequences like &&).

The invocation would look like this:

CompileDaemon --build "go mod vendor" --build "go build" .

This would also not add the ability to do something like --build "go mod vendor || (echo "no update" && go build)" but on the other hand it does not suggest that it is capable of doing that. For more complex cases I would always recommend to use shell scripts and execute them instead anyway.

What do you think?

nikolaigut commented 3 years ago

@githubnemo many thanks for your review and suggestions for improvement.

I've changed to code to allow using the --build flag multiple times instead of using the shell separator &&. Also, I extracted the functionality to run a build command into a separate method.

nikolaigut commented 3 years ago

@githubnemo I've added some more log events.

nikolaigut commented 3 years ago

@githubnemo thanks for your change suggestions.

githubnemo commented 3 years ago

Great addition, thanks for your work! :)