Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add param method for KotlinScript usage #4

Open
Flamenco opened this issue Oct 4, 2018 · 1 comment
Open

Add param method for KotlinScript usage #4

Flamenco opened this issue Oct 4, 2018 · 1 comment

Comments

@Flamenco
Copy link

Flamenco commented Oct 4, 2018

Using KotlinScript, I cannot set params because method names in closure start with a hyphen.

Please add a param method to DefaultMagickSpec

    val resize_images by creating(com.eowise.imagemagick.tasks.Magick::class) {
        group = "build"

        val root = "static/images/advanced-search"
        val width = 100

        convert(root, PatternSet().include("*.png"))
        into("static/images/advanced-search.$width")
        actions(closureOf<DefaultMagickSpec> {
            param( "-background", "none")
            param( "-resize", "${width}x")
            inputFile()
            outputFile()
        })
    }

Workaround 1: Use the params list and add manually in the closure

params.add(SimpleParam("-background"))
params.add(SimpleParam("none"))
params.add(SimpleParam("-resize"))
params.add(SimpleParam("${width}x"))

Workaround 2: Call methodMissing manually in the closure

this.methodMissing("-background", arrayOf(none))
this.methodMissing("-resize", arrayOf("${width}x"))
@bamapookie
Copy link
Contributor

Using the stack closure in Kotlin script is also broken. You need to add the parentheses as parameters as well.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants