Skip to content

Add inbuilt command logging capability #317

Description

@parrotcar00

Describe the problem

Whenever I write any bash script, I do this:

#!/bin/bash

set -ex

#Run some command foo
foo --bar --baz

The -x flag logs all bash commands as they're run. It's very useful when debugging things. I was looking for something that does the same in turtle.

Describe your solution
When using turtle in kotlin, I've made this helper function which I use:

fun loggedShellRun(command: String, args: List<String> = emptyList(), workingDir: File? = null): String {
    val commandString = "$command ${args.joinToString(" ")}"
    println("Exec: $commandString")
    val result = shellRun(command, args, workingDir)
    return result
}

and then I call it like:

loggedShellRun("foo", listOf("--bar", "--baz"), workingDir)

I think it would be a good idea to include this as a built in feature into the library.

Checklist

Additional context

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions