Files
herolib/lib/ui/factory.v
2024-12-25 08:40:56 +01:00

28 lines
707 B
V

module ui
import freeflowuniverse.herolib.ui.generic { ChannelType, UserInterface }
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.data.paramsparser
// import freeflowuniverse.herolib.ui.telegram
@[params]
pub struct UserInterfaceArgs {
pub mut:
channel ChannelType
params paramsparser.Params // to pass arguments to implementation
}
pub fn new(args UserInterfaceArgs) !UserInterface {
mut ch := match args.channel {
.console { console.new() }
else { panic("can't find channel") }
}
// .telegram { telegram.new() }
return UserInterface{
channel: ch
}
// return error("Channel type not understood, only console supported now.") // input is necessarily valid
}