[skip ci] add DesktopCliParsingSequence.md

This commit is contained in:
az 2023-02-24 17:07:59 +01:00
parent 0f7e3790ca
commit d6d42c0733
4 changed files with 57 additions and 15 deletions

View file

@ -0,0 +1,39 @@
```plantuml
@startuml
autonumber
skinparam sequenceBox {
borderColor White
}
participant User
User -> Application ++ : main(args...)
Application -> CliArgumentsParser : create
CliArgumentsParser -> ArgParser : subcommands
Application -> CliArgumentsParser : parseCommand
CliArgumentsParser -> ArgParser : super.parse
CliArgumentsParser -> CliTargetCommand : create()
CliTargetCommand -> CliTargetCommand : parseRemoteTarget
alt passwordInteractive == true
CliTargetCommand -> PromptSecretSource : prompt-for-password
end
CliArgumentsParser -> DesktopCliCommand : create(desktopType, cliTargetCmd, ...)
CliArgumentsParser --> Application: desktopCliCommand
Application -> DesktopCliCommand : isValid ?
Application -> CliUtils : createProvInstance
ProvInstance <- CliUtils : create
alt target.isValidLocal
CliUtils -> CliUtils : createLocalProv
else target.isValidRemote
CliUtils -> CliUtils : createRemote
end
Application -> DesktopService1 : provisionDesktopCommand ( provInstance, desktopCliCommand )
DesktopService1 -> DesktopService2 : provisionDesktop( config )
DesktopService1 -> ConfigRepository : getConfig
@enduml
```

View file

@ -3,7 +3,6 @@ package org.domaindrivenarchitecture.provs.configuration.application
import kotlinx.cli.ArgParser import kotlinx.cli.ArgParser
import kotlinx.cli.ArgType import kotlinx.cli.ArgType
import kotlinx.cli.default import kotlinx.cli.default
import org.domaindrivenarchitecture.provs.configuration.domain.TargetCliCommand
open class CliTargetParser(name: String) : ArgParser(name) { open class CliTargetParser(name: String) : ArgParser(name) {
val target by argument( val target by argument(
@ -17,13 +16,3 @@ open class CliTargetParser(name: String) : ArgParser(name) {
"prompt for password for remote target", "prompt for password for remote target",
).default(false) ).default(false)
} }
fun parseTarget(
programName: String = "provs",
args: Array<String>
): TargetCliCommand {
val parser = CliTargetParser(programName)
parser.parse(args)
return TargetCliCommand(parser.target, parser.passwordInteractive)
}

View file

@ -25,12 +25,14 @@ open class CliArgumentsParser(name: String) : CliTargetParser(name) {
val module = modules.first { it.parsed } val module = modules.first { it.parsed }
return DesktopCliCommand( val targetCliCommand = TargetCliCommand(
DesktopType.valueOf(module.name.uppercase()),
TargetCliCommand(
target, target,
passwordInteractive passwordInteractive
), )
return DesktopCliCommand(
DesktopType.valueOf(module.name.uppercase()),
targetCliCommand,
module.configFileName, module.configFileName,
module.onlyModules module.onlyModules
) )

View file

@ -1,9 +1,21 @@
package org.domaindrivenarchitecture.provs.configuration.application package org.domaindrivenarchitecture.provs.configuration.application
import org.domaindrivenarchitecture.provs.configuration.domain.TargetCliCommand
import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
private fun parseTarget(
args: Array<String>
): TargetCliCommand {
val parser = CliTargetParser("provs")
parser.parse(args)
return TargetCliCommand(parser.target, parser.passwordInteractive)
}
internal class CliTargetParserTest { internal class CliTargetParserTest {
@Test @Test