mirror of
https://github.com/corda/corda.git
synced 2025-04-19 08:36:39 +00:00
Merge remote-tracking branch 'open/master' into os-merge-c79dd80
This commit is contained in:
commit
df6903b52f
@ -18,7 +18,7 @@ class NodeCmdLineOptions {
|
||||
names = ["-b", "--base-directory"],
|
||||
description = ["The node working directory where all the files are kept."]
|
||||
)
|
||||
var baseDirectory: Path = Paths.get(".")
|
||||
var baseDirectory: Path = Paths.get(".").toAbsolutePath().normalize()
|
||||
|
||||
@Option(
|
||||
names = ["-f", "--config-file"],
|
||||
@ -57,7 +57,7 @@ class NodeCmdLineOptions {
|
||||
names = ["-t", "--network-root-truststore"],
|
||||
description = ["Network root trust store obtained from network operator."]
|
||||
)
|
||||
var networkRootTrustStorePath = Paths.get("certificates") / "network-root-truststore.jks"
|
||||
var networkRootTrustStorePath: Path = baseDirectory / "certificates" / "network-root-truststore.jks"
|
||||
|
||||
@Option(
|
||||
names = ["-p", "--network-root-truststore-password"],
|
||||
|
@ -15,20 +15,18 @@ class NodeCmdLineOptionsTest {
|
||||
|
||||
companion object {
|
||||
private lateinit var workingDirectory: Path
|
||||
private lateinit var buildDirectory: Path
|
||||
|
||||
@BeforeClass
|
||||
@JvmStatic
|
||||
fun initDirectories() {
|
||||
workingDirectory = Paths.get(".").normalize().toAbsolutePath()
|
||||
buildDirectory = workingDirectory.resolve("build")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `no command line arguments`() {
|
||||
assertThat(parser.cmdLineOptions.baseDirectory.normalize().toAbsolutePath()).isEqualTo(workingDirectory)
|
||||
assertThat(parser.cmdLineOptions.configFile.normalize().toAbsolutePath()).isEqualTo(workingDirectory / "node.conf")
|
||||
assertThat(parser.cmdLineOptions.baseDirectory).isEqualTo(workingDirectory)
|
||||
assertThat(parser.cmdLineOptions.configFile).isEqualTo(workingDirectory / "node.conf")
|
||||
assertThat(parser.verbose).isEqualTo(false)
|
||||
assertThat(parser.loggingLevel).isEqualTo(Level.INFO)
|
||||
assertThat(parser.cmdLineOptions.nodeRegistrationOption).isEqualTo(null)
|
||||
@ -40,5 +38,6 @@ class NodeCmdLineOptionsTest {
|
||||
assertThat(parser.cmdLineOptions.unknownConfigKeysPolicy).isEqualTo(UnknownConfigKeysPolicy.FAIL)
|
||||
assertThat(parser.cmdLineOptions.devMode).isEqualTo(null)
|
||||
assertThat(parser.cmdLineOptions.clearNetworkMapCache).isEqualTo(false)
|
||||
assertThat(parser.cmdLineOptions.networkRootTrustStorePath).isEqualTo(workingDirectory / "certificates" / "network-root-truststore.jks")
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import org.fusesource.jansi.AnsiConsole
|
||||
import org.slf4j.event.Level
|
||||
import picocli.CommandLine
|
||||
import picocli.CommandLine.*
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import kotlin.system.exitProcess
|
||||
import java.util.*
|
||||
@ -45,22 +46,24 @@ interface Validated {
|
||||
|
||||
/** This is generally covered by commons-lang. */
|
||||
object CordaSystemUtils {
|
||||
const val OS_NAME = "os.name"
|
||||
private const val OS_NAME = "os.name"
|
||||
private const val MAC_PREFIX = "Mac"
|
||||
private const val WIN_PREFIX = "Windows"
|
||||
|
||||
const val MAC_PREFIX = "Mac"
|
||||
const val WIN_PREFIX = "Windows"
|
||||
|
||||
fun isOsMac() = getOsName().startsWith(MAC_PREFIX)
|
||||
fun isOsWindows() = getOsName().startsWith(WIN_PREFIX)
|
||||
fun getOsName() = System.getProperty(OS_NAME)
|
||||
fun isOsMac(): Boolean = getOsName().startsWith(MAC_PREFIX)
|
||||
fun isOsWindows(): Boolean = getOsName().startsWith(WIN_PREFIX)
|
||||
fun getOsName(): String = System.getProperty(OS_NAME)
|
||||
}
|
||||
|
||||
fun CordaCliWrapper.start(args: Array<String>) {
|
||||
this.args = args
|
||||
|
||||
// This line makes sure ANSI escapes work on Windows, where they aren't supported out of the box.
|
||||
AnsiConsole.systemInstall()
|
||||
|
||||
val cmd = CommandLine(this)
|
||||
this.args = args
|
||||
// Make sure any provided paths are absolute. Relative paths have caused issues and are less clear in logs.
|
||||
cmd.registerConverter(Path::class.java) { Paths.get(it).toAbsolutePath().normalize() }
|
||||
cmd.commandSpec.name(alias)
|
||||
cmd.commandSpec.usageMessage().description(description)
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user