dolt icon indicating copy to clipboard operation
dolt copied to clipboard

Embed cli command in `dolt sql`

Open macneale4 opened this issue 1 year ago • 3 comments

It would be really cool is we could invert to control of CLI and SQL Shell. Example:

db4> insert into tbl values (42);
Query OK, 1 row affected (0.00 sec)
mydb> /diff
diff --dolt a/tbl b/tbl
--- a/tbl
+++ b/tbl
+---+----+
|   | i  |
+---+----+
| + | 42 |
+---+----+
mydb>

The nice thing about this is that the session persists in the connection, so you could run stored procedures or cli commands and they would have the same effect.

Simple prototype. https://github.com/dolthub/dolt/tree/macneale4/slash_bang

It actually surprised me when I was able to commit. I'll attach a screen shot.

macneale4 avatar Oct 25 '23 09:10 macneale4

Screenshot 2023-10-25 at 2 17 19 AM

macneale4 avatar Oct 25 '23 09:10 macneale4

This is awesome. But how did you specify the commit message in the example?

nicktobey avatar Oct 25 '23 22:10 nicktobey

I specified no args, so the commit command started my editor, just as it would if executed directly. I was surprised it worked, which is why "whoa" was all I had to say about it

macneale4 avatar Oct 26 '23 18:10 macneale4