ENT-2653: Introducing CommonCliConstants (#4265)

This commit is contained in:
Viktor Kolomeyko 2018-11-20 17:15:48 +00:00 committed by GitHub
parent f64eae8fdb
commit 0fe7f513e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 5 deletions

View File

@ -3,6 +3,7 @@ package net.corda.node
import com.typesafe.config.Config
import com.typesafe.config.ConfigException
import com.typesafe.config.ConfigFactory
import net.corda.cliutils.CommonCliConstants.BASE_DIR
import net.corda.common.configuration.parsing.internal.Configuration
import net.corda.common.validation.internal.Validated
import net.corda.common.validation.internal.Validated.Companion.invalid
@ -23,7 +24,7 @@ open class SharedNodeCmdLineOptions {
private val logger by lazy { loggerFor<SharedNodeCmdLineOptions>() }
}
@Option(
names = ["-b", "--base-directory"],
names = ["-b", BASE_DIR],
description = ["The node working directory where all the files are kept."]
)
var baseDirectory: Path = Paths.get(".").toAbsolutePath().normalize()

View File

@ -1,8 +1,7 @@
package net.corda.node.internal
import net.corda.cliutils.CommonCliConstants.BASE_DIR
import net.corda.core.internal.div
import net.corda.node.InitialRegistrationCmdLineOptions
import net.corda.node.internal.subcommands.InitialRegistrationCli
import net.corda.nodeapi.internal.config.UnknownConfigKeysPolicy
import org.assertj.core.api.Assertions.assertThat
import org.junit.BeforeClass
@ -44,7 +43,7 @@ class NodeStartupTest {
@Test
fun `--base-directory`() {
CommandLine.populateCommand(startup, "--base-directory", (workingDirectory / "another-base-dir").toString())
CommandLine.populateCommand(startup, BASE_DIR, (workingDirectory / "another-base-dir").toString())
assertThat(startup.cmdLineOptions.baseDirectory).isEqualTo(workingDirectory / "another-base-dir")
assertThat(startup.cmdLineOptions.configFile).isEqualTo(workingDirectory / "another-base-dir" / "node.conf")
assertThat(startup.cmdLineOptions.networkRootTrustStorePathParameter).isEqualTo(null)

View File

@ -6,6 +6,7 @@ import com.typesafe.config.ConfigFactory
import com.typesafe.config.ConfigRenderOptions
import com.typesafe.config.ConfigValueFactory
import net.corda.client.rpc.internal.createCordaRPCClientWithSslAndClassLoader
import net.corda.cliutils.CommonCliConstants.BASE_DIR
import net.corda.core.concurrent.CordaFuture
import net.corda.core.concurrent.firstOf
import net.corda.core.flows.FlowLogic
@ -830,7 +831,7 @@ class DriverDSLImpl(
writeConfig(handle.baseDirectory, "web-server.conf", handle.toWebServerConfig())
return ProcessUtilities.startJavaProcess(
className = className, // cannot directly get class for this, so just use string
arguments = listOf("--base-directory", handle.baseDirectory.toString()),
arguments = listOf(BASE_DIR, handle.baseDirectory.toString()),
jdwpPort = debugPort,
extraJvmArguments = listOf("-Dname=node-${handle.p2pAddress}-webserver") +
inheritFromParentProcess().map { "-D${it.first}=${it.second}" },

View File

@ -190,6 +190,13 @@ abstract class CordaCliWrapper(alias: String, description: String) : CliWrapperB
fun printlnWarn(message: String) = System.err.println(message)
}
/**
* Useful commonly used constants applicable to many CLI tools
*/
object CommonCliConstants {
const val BASE_DIR = "--base-directory"
}
/**
* Converter from String to slf4j logging Level.
*/