Skip to content

when using a compiled mage binary, the verbose flag isn't propagated #248

@Etomyutikos

Description

@Etomyutikos

When using a pre-compiled static mage binary, the -v flag does not produce the proper output.

Using this simple example:

func ShowVerboseDep() error {
	sh.Run("echo", "hello, mage!")
	return nil
}

func ShowVerbose() error {
	mg.Deps(ShowVerboseDep)
	sh.Run("echo", "goodbye, mage!")
	return nil
}

Output:

$ mage -v showverbose
Running target: ShowVerbose
Running dependency: ShowVerboseDep
exec: echo hello, mage!
hello, mage!
exec: echo goodbye, mage!
goodbye, mage!
$ ./mage -v showverbose
Running target: ShowVerbose
exec: echo hello, mage!
exec: echo goodbye, mage!

We're missing both the shell output and the dependency log lines.

When using the mage command directly, mage sets the MAGEFILE_VERBOSE environment variable based on the -v flag (see here).

However, the generated mage_output_file.go from which the compiled binary is built does no such thing.

This is relevant because both sh and mg inspect the MAGEFILE_VERBOSE environment variable (see here); there doesn't appear to be any other way to signal to these libraries that we want verbose output.

I propose we update the generated mage_output_file.go to set the MAGEFILE_VERBOSE environment variable just like we do for the mage command.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions