joelmccracken / reddup

Helping you keep your workstation nice and tidy
BSD 3-Clause "New" or "Revised" License
31 stars 6 forks source link

make all action handlers "forcable" via CLI, and therefore scriptable. #13

Open joelmccracken opened 4 years ago

joelmccracken commented 4 years ago

Considering @vladciobanu made #10 , I wonder if it would make sense to have a force option for every interactive action?

And this makes me wonder if there would be a way to serialize the data structure automatically? That might actually be really nice, but I don't know how it would be done.

What would be cool with this is that you could write a shell script that automatically interacts with the CLI.

eviefp commented 4 years ago

What about some DSL instead? Say we have this sort of ADT that expresses the states we may find the repository, like "Uncomitted", "Unpushed", etc. We could then have a DSL that essentially allows us to pattern match over these states and return an "action". We could run this action repeatedly until it returns the "Done" action.

The actions could be things that we'd expect to use often like commit, push, pull, set upstream, etc., but also perhaps just custom shell commands in case the user just wants to do something we didn't expect.

We could even allow users to store multiple such handlers, and pick and choose their favorite. I expect we could remove some of our code and move it to handlers and use those as some sort of "stdlib"/examples.

So essentially, instead of throwing out json, I'm saying, why not write our own specific language for this :)

joelmccracken commented 4 years ago

sure, the only reason i picked json is because it can integrate with jq, a lot of other languages have good support for it. My mental model is to create ADTs that have ToJSON/FromJSON instances, so it would be able to support both fairly naturally.