Skip to content

Commit

Permalink
ENT-2653: Introducing CommonCliConstants (corda#4265)
Browse files Browse the repository at this point in the history
  • Loading branch information
vkolomeyko authored Nov 20, 2018
1 parent f64eae8 commit 0fe7f51
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion node/src/main/kotlin/net/corda/node/NodeCmdLineOptions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 0fe7f51

Please sign in to comment.