Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit dd3faa7

Browse files
committed
Updated CLI flags.
1 parent e322de6 commit dd3faa7

File tree

3 files changed

+19
-36
lines changed

3 files changed

+19
-36
lines changed

src/main/scala/org/codeoverflow/chatoverflow/ChatOverflow.scala

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import org.codeoverflow.chatoverflow.registry.TypeRegistry
2121
class ChatOverflow(val pluginFolderPath: String,
2222
val configFolderPath: String,
2323
val requirementPackage: String,
24-
val requirePasswordOnStartup: Boolean,
2524
val logOutputOnConsole: Boolean)
2625
extends WithLogger {
2726

@@ -62,13 +61,6 @@ class ChatOverflow(val pluginFolderPath: String,
6261
ConnectorRegistry.setTypeRegistry(typeRegistry)
6362
logger debug "Finished updating type registry."
6463

65-
if (requirePasswordOnStartup && !loaded) {
66-
logger debug "Loading configs and credentials."
67-
askForPassword()
68-
load()
69-
logger debug "Finished loading configs and credentials."
70-
}
71-
7264
logger debug "Finished initialization."
7365
}
7466

@@ -107,14 +99,6 @@ class ChatOverflow(val pluginFolderPath: String,
10799
System.setSecurityManager(new SecurityManager)
108100
}
109101

110-
private def askForPassword(): Unit = {
111-
val password = if (System.console() != null)
112-
System.console().readPassword("Please enter password (Input hidden) > ")
113-
else
114-
scala.io.StdIn.readLine("Please enter password (Input NOT hidden) > ").toCharArray
115-
credentialsService.setPassword(password)
116-
}
117-
118102
/**
119103
* Saves all settings and credentials to the corresponding files in the config folder.
120104
*/

src/main/scala/org/codeoverflow/chatoverflow/Launcher.scala

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ object Launcher extends WithLogger {
2323

2424
// The complete project visible trough one single instance
2525
val chatOverflow = new ChatOverflow(config.pluginFolderPath,
26-
config.configFolderPath, config.requirementPackage, config.requirePasswordOnStartup, config.pluginLogOutputOnConsole)
26+
config.configFolderPath, config.requirementPackage, config.pluginLogOutputOnConsole)
2727

2828
// Initialize chat overflow
2929
chatOverflow.init()
@@ -38,15 +38,20 @@ object Launcher extends WithLogger {
3838
startServer(chatOverflow, config.webServerPort)
3939

4040
// Start plugins if specified
41-
if (chatOverflow.isLoaded && config.startupPlugins.nonEmpty) {
42-
for (instanceName <- config.startupPlugins) {
43-
val instance = chatOverflow.pluginInstanceRegistry.getPluginInstance(instanceName)
41+
if (config.startupPlugins.nonEmpty) {
42+
if (chatOverflow.isLoaded) {
43+
logger info "Starting startup plugins."
44+
for (instanceName <- config.startupPlugins) {
45+
val instance = chatOverflow.pluginInstanceRegistry.getPluginInstance(instanceName)
4446

45-
if (instance.isEmpty) {
46-
println(s"No plugin instance named '$instanceName' was registered.")
47-
} else {
48-
instance.get.start()
47+
if (instance.isEmpty) {
48+
logger warn s"No plugin instance named '$instanceName' was registered."
49+
} else {
50+
instance.get.start()
51+
}
4952
}
53+
} else {
54+
logger warn "Unable to run startup plugins. No/wrong password supplied."
5055
}
5156
}
5257
}

src/main/scala/org/codeoverflow/chatoverflow/ui/CLI.scala

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,20 @@ object CLI {
2222
opt[String]('r', "requirementPackage").action((x, c) =>
2323
c.copy(requirementPackage = x)).text("path to the package where all requirements are defined")
2424

25-
// Subject of change. After GUI will be -l (for login)
26-
opt[Unit]('n', "noPassword").action((_, c) =>
27-
c.copy(requirePasswordOnStartup = false)).text("set this flag to disable password checking on framework startup")
28-
2925
opt[String]('l', "login").action((x, c) =>
30-
c.copy(loginPassword = x.toCharArray)).text("the password to login to chat overflow (not recommended, has to be combined with -n)")
26+
c.copy(loginPassword = x.toCharArray)).text("the password to login to chat overflow on framework startup")
3127

3228
opt[Seq[String]]('s', "start").action((x, c) =>
33-
c.copy(startupPlugins = x)).text("a comma-separated list of plugin instances to start after login (has to be combined with -n and -l)")
29+
c.copy(startupPlugins = x)).text("a comma-separated list of plugin instances to start after login (has to be combined with -l)")
3430

3531
opt[String]('d', "pluginDataFolder").action((x, c) =>
3632
c.copy(pluginDataPath = x)).text("path to the data folder, accessible from within plugins")
3733

3834
opt[Int]('w', "webServerPort").action((x, c) =>
39-
c.copy(webServerPort = x)).text("default web server port, used eg. for the rest api")
35+
c.copy(webServerPort = x)).text("default web server port, used eg. for the rest api and web gui")
4036

41-
// Subject of change. After GUI will be -o (enablePluginOutput)
42-
opt[Unit]('z', "disableLogOutputOnConsole").action((_, c) =>
43-
c.copy(pluginLogOutputOnConsole = false)).text("set this flag to disable plugin log output on console")
37+
opt[Unit]('o', "enablePluginOutput").action((_, c) =>
38+
c.copy(pluginLogOutputOnConsole = true)).text("set this flag to enable plugin log output on console")
4439

4540
help("help").hidden().text("prints this usage text")
4641

@@ -67,10 +62,9 @@ object CLI {
6762
case class Config(pluginFolderPath: String = "plugins/",
6863
configFolderPath: String = "config/",
6964
requirementPackage: String = "org.codeoverflow.chatoverflow.requirement",
70-
requirePasswordOnStartup: Boolean = true,
7165
pluginDataPath: String = "data",
7266
webServerPort: Int = 2400,
73-
pluginLogOutputOnConsole: Boolean = true,
67+
pluginLogOutputOnConsole: Boolean = false,
7468
loginPassword: Array[Char] = Array[Char](),
7569
startupPlugins: Seq[String] = Seq[String]())
7670

0 commit comments

Comments
 (0)