Closed jmfayard closed 2 years ago
I'm not keen on a mutable command that actually alters how all the other commands work. I think I would probably instead offer an 'echo' command that can take a ShellScript as input or something along those lines.
The idea of Turtle is to focus on the core of running commands and to offer a limited set of the most commonly used commands that are likely to be used by many users. The API of Turtle should be designed so that users can extend it whenever they need to. From a maintenance perspective I think it is better to maintain a really extensible API where pretty much any 'command' can be added to it by users, rather to somehow try and implement every command people might need as everyone will need different commands.
I feel like this 'dry-run' command feels quite specific and may be best as an extension you use. However, if changes are needed to the API to allow an extension like this to be written, then I would agree those should be made.
Many commands that either can take a long time to complete or can have potentially big side effects have a dry run flag.
That's the case for Gradle for example: running ./gradlew check
can take a long time.
But if I just want to check that the Gradle configuration is OK, running gradle --dry-run check
is super fast.
I feel like this 'dry-run' command feels quite specific
What was too specific in my issue is to do that for git
only.
That actually makes sense for all commands.
However, if changes are needed to the API to allow an extension like this to be written, then I would agree those should be made.
Yep, com.lordcodes.turtle.ShellScript.runCommand()
would need to be modified so that instead of executing the command, it does something like
println("$ $command ${arguments.joinToString(" ")}
That is a very fair argument, so will make this issue to add a "dry-run" version for any command.
The slight difference, is from your example, Gradle dry-run mode is much more than just printing out your command. It allows Gradle to output the tasks it would execute so you can see the impact of running the command.
Whereas what you are describing will literally just print out the command you told it to run, so it is more of a "debugging" option to check arguments that are passed in at run-time etc.
What is the difference in your suggestion with just adding an 'echo' command into your code that prints out the result of a previous git command to see what its value is? As what you are describing is just something that prints out the command.
The difference would be that I can run my entire scripts and see the list of commands that would be executed, having as output something like a Bash script. And for that I just have to configure the dry run mode in one place, instead of modifying all my commands.
So you are suggesting, dry run would be a mutable mode that you enable and then all the following commands would run using it. There may be a way to build this into the API as an input argument shellRun(dryRun = true)
or a different function shellDryRun { ... }
.
Nice, thanks 👍
Describe the problem
Assuming I have a script that does a lot of git stuff, I would like to have a dry run mode to check that my git syntax is correct before actually doing a git operation
Describe your solution
fun GitCommands.dryRunMode()
fun GitCommands.gitCommand()
so that it doesecho git command something
instead ofgit command something
when dry run is enabledChecklist