Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Scripting #45

Open
juraj-hrivnak opened this issue Oct 11, 2024 · 0 comments
Open

Scripting #45

juraj-hrivnak opened this issue Oct 11, 2024 · 0 comments
Assignees
Labels
enhancement Enhancement of an existing feature new feature New feature request

Comments

@juraj-hrivnak
Copy link
Owner

juraj-hrivnak commented Oct 11, 2024

Scripting

The idea is to provide a way to customize Pakku's behaviour when exporting.

Pakku is designed to support scripting under the hood through its API.
The main aspects that will be scriptable are Export Profiles and Export Rules. See #18.

Implementation

For the scripting, we will use Kotlin Scripting with a custom scripting host packaged into Pakku and a script definition which would import the Pakku API by default.

The extension of Pakku scripts will be: .pakku.kts.
These scripts will be either read from the Pakku directory (.pakku/) or a custom-defined directory using the config file.

Example usage of scripting:

exportProfile(name = "modlist") {
    ExportRule {
        val modListModel = ModListModel()

        when (it)
        {
            is ExportingProject -> it.exportToModList(modListModel)
            is Finished         -> it.createJsonFile(modListModel, "overrides", "modlist.json")
            else                -> it.ignore()
        }
    }
}

fun ExportingProject.exportToModList(modListModel: ModListModel) =
    ruleResult(message = "exporting $project to modlist", Packaging.Action {
        modListModel.mods.add(project)
        null // Return no error
    })

data class ModListModel(val mods: MutableList<Project> = mutableListOf())

Other

The question is whether and how other aspects of Pakku should be scriptable.
Suggestions and possible implementation ideas are very welcomed.

@juraj-hrivnak juraj-hrivnak added the enhancement Enhancement of an existing feature label Oct 11, 2024
@juraj-hrivnak juraj-hrivnak self-assigned this Oct 11, 2024
@github-project-automation github-project-automation bot moved this to Ready🚀 in Pakku project Oct 11, 2024
@juraj-hrivnak juraj-hrivnak added the new feature New feature request label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement of an existing feature new feature New feature request
Projects
Status: Ready🚀
Development

No branches or pull requests

1 participant