WIP: Building hero
- The work is still in progress Co-authored-by: supermario <mariobassem12@gmail.com>
This commit is contained in:
@@ -11,7 +11,7 @@ import freeflowuniverse.herolib.osal.screen
|
||||
import os
|
||||
|
||||
// install lighttpd will return true if it was already installed
|
||||
pub fn installll(args InstallArgs) ! {
|
||||
pub fn install(args InstallArgs) ! {
|
||||
// make sure we install base on the node
|
||||
base.install()!
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
module tailwind
|
||||
|
||||
import freeflowuniverse.herolib.osal
|
||||
import freeflowuniverse.herolib.core
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.core.texttools
|
||||
import freeflowuniverse.herolib.core.pathlib
|
||||
import os
|
||||
|
||||
pub const version = '3.4.12'
|
||||
|
||||
@@ -2,9 +2,9 @@ module tailwind
|
||||
|
||||
import freeflowuniverse.herolib.core.base
|
||||
import freeflowuniverse.herolib.core.playbook
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.sysadmin.startupmanager
|
||||
import freeflowuniverse.herolib.osal.zinit
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import time
|
||||
|
||||
__global (
|
||||
@@ -17,65 +17,59 @@ __global (
|
||||
@[params]
|
||||
pub struct ArgsGet {
|
||||
pub mut:
|
||||
name string
|
||||
}
|
||||
|
||||
fn args_get(args_ ArgsGet) ArgsGet {
|
||||
mut model := args_
|
||||
if model.name == '' {
|
||||
model.name = tailwind_default
|
||||
}
|
||||
if model.name == '' {
|
||||
model.name = 'default'
|
||||
}
|
||||
return model
|
||||
name string = 'default'
|
||||
}
|
||||
|
||||
pub fn get(args_ ArgsGet) !&Tailwind {
|
||||
mut args := args_get(args_)
|
||||
if args.name !in tailwind_global {
|
||||
if args.name == 'default' {
|
||||
if !config_exists(args) {
|
||||
if default {
|
||||
mut context := base.context() or { panic('bug') }
|
||||
context.hero_config_set('tailwind', model.name, heroscript_default()!)!
|
||||
}
|
||||
}
|
||||
load(args)!
|
||||
}
|
||||
}
|
||||
return tailwind_global[args.name] or {
|
||||
println(tailwind_global)
|
||||
panic('could not get config for ${args.name} with name:${model.name}')
|
||||
}
|
||||
return &Tailwind{}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////# LIVE CYCLE MANAGEMENT FOR INSTALLERS ///////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fn startupmanager_get(cat zinit.StartupManagerType) !startupmanager.StartupManager {
|
||||
// unknown
|
||||
// screen
|
||||
// zinit
|
||||
// tmux
|
||||
// systemd
|
||||
match cat {
|
||||
.zinit {
|
||||
console.print_debug('startupmanager: zinit')
|
||||
return startupmanager.get(cat: .zinit)!
|
||||
}
|
||||
.systemd {
|
||||
console.print_debug('startupmanager: systemd')
|
||||
return startupmanager.get(cat: .systemd)!
|
||||
}
|
||||
else {
|
||||
console.print_debug('startupmanager: auto')
|
||||
return startupmanager.get()!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@[params]
|
||||
pub struct InstallArgs {
|
||||
pub mut:
|
||||
reset bool
|
||||
}
|
||||
|
||||
// switch instance to be used for tailwind
|
||||
pub fn switch(name string) {
|
||||
tailwind_default = name
|
||||
}
|
||||
|
||||
pub fn (mut self Tailwind) install(args InstallArgs) ! {
|
||||
switch(self.name)
|
||||
if args.reset {
|
||||
destroy_()!
|
||||
}
|
||||
if !(installed_()!) {
|
||||
if args.reset || (!installed_()!) {
|
||||
install_()!
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (mut self Tailwind) destroy() ! {
|
||||
switch(self.name)
|
||||
|
||||
destroy_()!
|
||||
}
|
||||
|
||||
// switch instance to be used for tailwind
|
||||
pub fn switch(name string) {
|
||||
tailwind_default = name
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user