Skip to content

Conversation

cincodenada
Copy link

@cincodenada cincodenada commented Apr 19, 2018

I had heard of picotool's build functionality and hoped it had this feature. No dice, but I was glad to see it was on the list (#25). So, I went ahead and threw together a basic implementation.

This could be polished further, but I think it's pretty functional already. It adds two flags to the build command. --watch[=dir] will cause picotool to sit and watch the given directory (default current directory) for changes. --watch-glob allows specifying what files to watch - by default, it watches *.lua,*.p8,*.png. An obvious improvement would be to watch the files specified, but this was simpler to implement and does the trick for now.

When any change to a watched file happens, it just runs do_build with whatever other arguments are provided, then goes back to watching.

It's mostly a thin wrapper around watchdog, which I found after a brief search. It met my criteria of cross-platform and seeming mature/supported enough, and using it was actually super nice. I made the include optional - so if it is not there, the rest of picotool will work, but --watch will give a nice message saying to install watchdog to enable it. The stub classes to squelch errors in the code that requires it is my design, I don't know if there's some more standard way of doing that.

I'm certainly open to feedback, on substance or style - for one, I still need to add a couple tests for it. Give it a whirl and let me know what you think. After using it for a bit, it does the job but seems a bit overeager...I'll keep tweaking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant