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

add default field into Key #64

Open
icreator opened this issue Nov 19, 2022 · 1 comment
Open

add default field into Key #64

icreator opened this issue Nov 19, 2022 · 1 comment

Comments

@icreator
Copy link

icreator commented Nov 19, 2022

Please add default field into Key:

    val nameKey = Key("name", stringType, "DefaultName")
    val name = config[nameKey] /// if not contains in CONFIG -> ="DefaultName"

If use -h command it will print:

Description of NAME. Default value: DefaultName

And if not setted in configuration - use Deafult Value

instead I do now:

    val connectiontimeoutKey = Key("connection.timeout", intType)
    fun getConnectionTimeout(): Int {
        return if (connectiontimeoutKey in vals) vals[connectiontimeoutKey]
        else DEFAULT_CONNECTION_TIMEOUT
    }

but I need:

    val connectiontimeoutKey = Key("connection.timeout", intType, DEFAULT_CONNECTION_TIMEOUT)
    fun getConnectionTimeout(): Int {
        return vals[connectiontimeoutKey]
    }
@icreator
Copy link
Author

icreator commented Nov 21, 2022

IDEA!
instead of Key("name", stringType, "DefaultName")

use Key("name", "DefaultName")

defaultValue - has class type already

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

No branches or pull requests

1 participant