| ▲ | skissane 13 hours ago | |
In one (internal) CLI I maintain, I actually put the `if not dry_run:` inside the code which calls the REST API, because I have a setting to log HTTP calls as CURL commands, and that way in dry-run mode I can get the HTTP calls it would have made without it actually making them. And this works well if your CLI command is simply performing a single operation, e.g. call this REST API But the moment it starts to do anything more complex: e.g. call API1, and then send the results of API1 to API2 – it becomes a lot more difficult Of course, you can simulate what API1 is likely to have returned; but suddenly you have something a lot more complex and error-prone than just `if not dry_run:` | ||
| ▲ | scruple 11 hours ago | parent | next [-] | |
Having 1 place (or just generally limiting them) that does the things keeps the dry_run check from polluting the entire codebase. I maintain a lot of CLI tooling that's run by headless VMs in automation pipelines and we do this with basically every single tool. | ||
| ▲ | iberator 4 hours ago | parent | prev [-] | |
What's your obsession with REST AND HTTP for console tools?! Rest bloat is insane. Kidss nowadays wants EVERYTHING to run over IP/TCP/https. Why?! Learn to write local tools first. | ||