From d5db49fa79d307fd7e938a8ea4e953f4051edeca Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Tue, 4 Jun 2019 16:56:58 +0100 Subject: [PATCH] initialize core --- cli/build.gradle | 4 +++ cli/src/main/groovy/com/muwire/cli/Cli.groovy | 35 +++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/cli/build.gradle b/cli/build.gradle index 88699dd0..d104c7e4 100644 --- a/cli/build.gradle +++ b/cli/build.gradle @@ -1,3 +1,7 @@ apply plugin : 'application' mainClassName = 'com.muwire.cli.Cli' + +dependencies { + compile project(":core") +} diff --git a/cli/src/main/groovy/com/muwire/cli/Cli.groovy b/cli/src/main/groovy/com/muwire/cli/Cli.groovy index caf7ac61..0ea71154 100644 --- a/cli/src/main/groovy/com/muwire/cli/Cli.groovy +++ b/cli/src/main/groovy/com/muwire/cli/Cli.groovy @@ -1,8 +1,39 @@ package com.muwire.cli +import com.muwire.core.Core +import com.muwire.core.MuWireSettings + class Cli { public static void main(String[] args) { - println "MuWire command-line interface" + def home = System.getProperty("user.home") + File.separator + ".MuWire" + home = new File(home) + if (!home.exists()) + home.mkdirs() + + def propsFile = new File(home,"MuWire.properties") + if (!propsFile.exists()) { + println "create props file ${propsFile.getAbsoluteFile()} before launching MuWire" + System.exit(1) + } + + def props = new Properties() + props.eachWithIndex { props.load(id) } + props = new MuWireSettings(props) + + Core core + try { + core = new Core(props, home, "0.0.7") + } catch (Exception bad) { + bad.printStackTrace(System.out) + println "Failed to initialize core, exiting" + System.exit(1) + } + + core.startServices() + + // now we begin + println "MuWire is ready" + Thread.sleep(Integer.MAX_VALUE) } -} +} \ No newline at end of file