Skip to content

Support running commands from strings #11

@justaugustus

Description

@justaugustus

From carolynvs/magex#26:

It would be nice to not have to specify the arguments as a string slice and instead pass a single space separated string.

shx.Run("go test ./...")

There is a library that can help with this, https://github.com/mattn/go-shellwords

You could extend this further and support newline separated commands

shx.Run(`
go build -o bin/stuff .
go test ./...
./bin/stuff --version
`)

If you were feeling really spicy, you could define a parser for a simplified Makefile syntax and then execute the Makefile in the same directory.

magefile.go
Makefile

magefile.go

//go:generate magic command to generate a magefile with extra targets based on the Makefile 

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions