snaptoken / leg

Tools for making step-by-step code walkthroughs
MIT License
132 stars 2 forks source link

Error: There is already a steps folder #2

Closed rnorth closed 7 years ago

rnorth commented 7 years ago

Perhaps my workflow isn't quite right, but I'm wondering if the leg undiff behaviour could be made more user friendly when the steps folder already exists.

As I'm lazy, I tried to reduce the commands I execute after making any kind of change to just a one-liner; leg diff && leg undiff && leg doc. As-is, my project seems to be small enough for it not to matter that I'm rebuilding everything from scratch (maybe this will change?).

However, the leg undiff step is failing with Error: There is already a steps folder.

It's pretty trivial, but could undiff be changed to either (a) delete and rewrite the steps folder, or (b) update the contents.

Right now I'm just including a rm -r steps command too, which gets the job done, but maybe there's a better solution!

paigeruten commented 7 years ago

Yes, the way the commands work right now isn't very ideal. It's the result of me originally using step folders to work on the kilo tutorial, and then gradually starting to use git more and more as I got more comfortable with git rebase.

I don't use the steps/ representation to make changes to steps anymore, and it sounds like you don't either, but I think some people might still find it useful, like if they aren't really comfortable using git for everything. So that's why leg doesn't want to overwrite the steps/ folder: it might have unsaved changes.

One solution that comes to mind is to have a leg sync command that updates all three representations to one of the representations, and leg doc could run the sync operation implicitly. The default representation you want to sync from could be specified in leg.yml. How does that sound?

rnorth commented 7 years ago

Thanks, yes I think that sounds good. As I mentioned, it's not hugely difficult right now, but a sync command sounds like a good thing (and is probably easier for new users to get their heads around)!

paigeruten commented 7 years ago

Okay, the sync command is implemented in 0.24.0. leg help sync explains how it works. You'll need to add the line :sync: repo to your leg.yml. The leg doc command automatically runs leg sync, so most of the time leg doc should be the only command you'll need.

rnorth commented 7 years ago

Great, thanks. We've tried this and it's simplified things a lot. Thank you! Richard