When mining in my survival world, I realized I wasn't happy with the default tunnel program. So I decided to make a custom program, re-writing the program from scratch without looking at the original code.
My code may be a bit messy, but I've tried to keep it organised. I may also have added too many comments, but I guess you can never be too safe.

Some of the features were inspired by the default excavation program, such as returning to the chest when its full, or printing have far it has done so far. I've ensured the turtle is entity, sand and obsidian proof.

I'm still patching out little issues here and there, but I'd like to hear feedback for this program.

https://pastebin.com/DAL9GEcg

Usage: Mine <length> <true/false>
The final argument is another feature I added, just because I'm inpatient. If I have pre-dug, say 10 blocks. but want to expand it, instead of starting from the very start, it'll walk to the end of the pre-dug tunnel before it mines.

The turtle digs in a 3x3 pattern and I haven't made it bedrock proof as It only moves horizontally, not vertically, so as long as you're sensible where you put this, it should run fine.

Edit: Quick note, this returns items into a chest, but depending on how much you mine, you may want to empty that chest often or transfer the items, otherwise the turtle may freeze waiting for you to update.
Edit 2: Forgot to mention, this program hasn't been made to check for fuel, yet. So if you're on a server or have your settings so that your turtles require fuel to move around, please ensure they're well fueled before using this program. I plan to fix this eventually.