Skip to content

Commit

Permalink
CORE-17606, CORE-15885: Remove SetCurrentNodeCommand
Browse files Browse the repository at this point in the history
As well as dependency on `com.github.stefanbirkner:system-lambda` library.
  • Loading branch information
vkolomeyko committed Oct 10, 2023
1 parent 8159658 commit b32bbcb
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 158 deletions.
8 changes: 1 addition & 7 deletions app/src/main/kotlin/net/corda/cli/application/Boot.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package net.corda.cli.application

import net.corda.cli.api.CordaCliPlugin
import net.corda.cli.application.commands.SetCurrentNodeCommand
import net.corda.cli.application.logger.LoggerStream
import net.corda.cli.application.utils.Files
import org.pf4j.CompoundPluginDescriptorFinder
import org.pf4j.DefaultPluginManager
import org.pf4j.ManifestPluginDescriptorFinder
Expand All @@ -17,8 +15,7 @@ fun main(vararg args: String) {
}

@CommandLine.Command(
name = "corda-cli",
subcommands = [SetCurrentNodeCommand::class]
name = "corda-cli"
)
class App {
@CommandLine.Option(names = ["-h", "--help", "-?", "-help"], usageHelp = true, description = ["Display help and exit."])
Expand All @@ -45,9 +42,6 @@ object Boot {
// Setup loggers to redirect sysOut and sysErr
LoggerStream.redirectSystemAndErrorOut()

// create storage dir if it doesn't exist
Files.cliHomeDir().mkdirs()

// Find and load the CLI plugins
val pluginsDir = System.getProperty("pf4j.pluginsDir", "./plugins")
val pluginManager = PluginManager(listOf(Paths.get(pluginsDir)))
Expand Down

This file was deleted.

10 changes: 0 additions & 10 deletions app/src/main/kotlin/net/corda/cli/application/dto/NodeProfile.kt

This file was deleted.

26 changes: 0 additions & 26 deletions app/src/main/kotlin/net/corda/cli/application/utils/Files.kt

This file was deleted.

This file was deleted.

33 changes: 0 additions & 33 deletions app/src/test/kotlin/net/corda/cli/application/utils/FilesTest.kt

This file was deleted.

1 change: 0 additions & 1 deletion plugins/example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ dependencies {

testImplementation project(":api")
testImplementation "org.pf4j:pf4j:${pf4jVersion}"
testImplementation "com.github.stefanbirkner:system-lambda:1.2.1"
testImplementation "org.junit.jupiter:junit-jupiter:${junitJupiterVersion}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}"
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,49 @@
package net.corda.cli.plugins.examples

import com.github.stefanbirkner.systemlambda.SystemLambda.tapSystemErrNormalized
import com.github.stefanbirkner.systemlambda.SystemLambda.tapSystemOutNormalized
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import picocli.CommandLine
import java.io.ByteArrayOutputStream
import java.io.PrintStream

class ExamplePluginTest {

companion object {
private fun tapSystemErr(function: () -> Int): String {
val initial = System.err

val byteArrayOutputStream = ByteArrayOutputStream()
System.setErr(PrintStream(byteArrayOutputStream))
try {
function()
} finally {
System.setErr(initial)
}

return String(byteArrayOutputStream.toByteArray()).replace("\r\n", "\n")
}

private fun tapSystemOut(function: () -> Int): String {
val initial = System.out

val byteArrayOutputStream = ByteArrayOutputStream()
System.setOut(PrintStream(byteArrayOutputStream))
try {
function()
} finally {
System.setOut(initial)
}

return String(byteArrayOutputStream.toByteArray()).replace("\r\n", "\n")
}
}

@Test
fun testNoOptionCommand() {

val app = ExamplePlugin.ExamplePluginEntry()

val outText = tapSystemErrNormalized {
val outText = tapSystemErr {
CommandLine(
app
).execute("")
Expand All @@ -35,7 +65,7 @@ class ExamplePluginTest {
fun testSubCommand() {

val app = ExamplePlugin.ExamplePluginEntry()
val outText = tapSystemOutNormalized {
val outText = tapSystemOut {
CommandLine(
app
).execute("sub-command")
Expand All @@ -48,7 +78,7 @@ class ExamplePluginTest {
fun testUnknownCommand() {

val app = ExamplePlugin.ExamplePluginEntry()
val outText = tapSystemErrNormalized {
val outText = tapSystemErr {
CommandLine(
app
).execute("unknown-command")
Expand Down

0 comments on commit b32bbcb

Please sign in to comment.