mirror of
https://github.com/corda/corda.git
synced 2025-06-16 14:18:20 +00:00
ENT-2653: Introducing CommonCliConstants (#4265)
This commit is contained in:
@ -3,6 +3,7 @@ package net.corda.node
|
|||||||
import com.typesafe.config.Config
|
import com.typesafe.config.Config
|
||||||
import com.typesafe.config.ConfigException
|
import com.typesafe.config.ConfigException
|
||||||
import com.typesafe.config.ConfigFactory
|
import com.typesafe.config.ConfigFactory
|
||||||
|
import net.corda.cliutils.CommonCliConstants.BASE_DIR
|
||||||
import net.corda.common.configuration.parsing.internal.Configuration
|
import net.corda.common.configuration.parsing.internal.Configuration
|
||||||
import net.corda.common.validation.internal.Validated
|
import net.corda.common.validation.internal.Validated
|
||||||
import net.corda.common.validation.internal.Validated.Companion.invalid
|
import net.corda.common.validation.internal.Validated.Companion.invalid
|
||||||
@ -23,7 +24,7 @@ open class SharedNodeCmdLineOptions {
|
|||||||
private val logger by lazy { loggerFor<SharedNodeCmdLineOptions>() }
|
private val logger by lazy { loggerFor<SharedNodeCmdLineOptions>() }
|
||||||
}
|
}
|
||||||
@Option(
|
@Option(
|
||||||
names = ["-b", "--base-directory"],
|
names = ["-b", BASE_DIR],
|
||||||
description = ["The node working directory where all the files are kept."]
|
description = ["The node working directory where all the files are kept."]
|
||||||
)
|
)
|
||||||
var baseDirectory: Path = Paths.get(".").toAbsolutePath().normalize()
|
var baseDirectory: Path = Paths.get(".").toAbsolutePath().normalize()
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package net.corda.node.internal
|
package net.corda.node.internal
|
||||||
|
|
||||||
|
import net.corda.cliutils.CommonCliConstants.BASE_DIR
|
||||||
import net.corda.core.internal.div
|
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 net.corda.nodeapi.internal.config.UnknownConfigKeysPolicy
|
||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
import org.junit.BeforeClass
|
import org.junit.BeforeClass
|
||||||
@ -44,7 +43,7 @@ class NodeStartupTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `--base-directory`() {
|
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.baseDirectory).isEqualTo(workingDirectory / "another-base-dir")
|
||||||
assertThat(startup.cmdLineOptions.configFile).isEqualTo(workingDirectory / "another-base-dir" / "node.conf")
|
assertThat(startup.cmdLineOptions.configFile).isEqualTo(workingDirectory / "another-base-dir" / "node.conf")
|
||||||
assertThat(startup.cmdLineOptions.networkRootTrustStorePathParameter).isEqualTo(null)
|
assertThat(startup.cmdLineOptions.networkRootTrustStorePathParameter).isEqualTo(null)
|
||||||
|
@ -6,6 +6,7 @@ import com.typesafe.config.ConfigFactory
|
|||||||
import com.typesafe.config.ConfigRenderOptions
|
import com.typesafe.config.ConfigRenderOptions
|
||||||
import com.typesafe.config.ConfigValueFactory
|
import com.typesafe.config.ConfigValueFactory
|
||||||
import net.corda.client.rpc.internal.createCordaRPCClientWithSslAndClassLoader
|
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.CordaFuture
|
||||||
import net.corda.core.concurrent.firstOf
|
import net.corda.core.concurrent.firstOf
|
||||||
import net.corda.core.flows.FlowLogic
|
import net.corda.core.flows.FlowLogic
|
||||||
@ -830,7 +831,7 @@ class DriverDSLImpl(
|
|||||||
writeConfig(handle.baseDirectory, "web-server.conf", handle.toWebServerConfig())
|
writeConfig(handle.baseDirectory, "web-server.conf", handle.toWebServerConfig())
|
||||||
return ProcessUtilities.startJavaProcess(
|
return ProcessUtilities.startJavaProcess(
|
||||||
className = className, // cannot directly get class for this, so just use string
|
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,
|
jdwpPort = debugPort,
|
||||||
extraJvmArguments = listOf("-Dname=node-${handle.p2pAddress}-webserver") +
|
extraJvmArguments = listOf("-Dname=node-${handle.p2pAddress}-webserver") +
|
||||||
inheritFromParentProcess().map { "-D${it.first}=${it.second}" },
|
inheritFromParentProcess().map { "-D${it.first}=${it.second}" },
|
||||||
|
@ -190,6 +190,13 @@ abstract class CordaCliWrapper(alias: String, description: String) : CliWrapperB
|
|||||||
fun printlnWarn(message: String) = System.err.println(message)
|
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.
|
* Converter from String to slf4j logging Level.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user