diff --git a/doc/DesktopCliParsingSequence.md b/doc/DesktopCliParsingSequence.md new file mode 100644 index 0000000..5ba2960 --- /dev/null +++ b/doc/DesktopCliParsingSequence.md @@ -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 + +``` \ No newline at end of file diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/configuration/application/CliTargetParser.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/configuration/application/CliTargetParser.kt index 6c3bccc..84d0629 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/configuration/application/CliTargetParser.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/configuration/application/CliTargetParser.kt @@ -3,7 +3,6 @@ package org.domaindrivenarchitecture.provs.configuration.application import kotlinx.cli.ArgParser import kotlinx.cli.ArgType import kotlinx.cli.default -import org.domaindrivenarchitecture.provs.configuration.domain.TargetCliCommand open class CliTargetParser(name: String) : ArgParser(name) { val target by argument( @@ -16,14 +15,4 @@ open class CliTargetParser(name: String) : ArgParser(name) { "p", "prompt for password for remote target", ).default(false) -} - -fun parseTarget( - programName: String = "provs", - args: Array -): TargetCliCommand { - val parser = CliTargetParser(programName) - parser.parse(args) - - return TargetCliCommand(parser.target, parser.passwordInteractive) } \ No newline at end of file diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/application/CliArgumentsParser.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/application/CliArgumentsParser.kt index 89d8aec..0dce95c 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/application/CliArgumentsParser.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/application/CliArgumentsParser.kt @@ -25,12 +25,14 @@ open class CliArgumentsParser(name: String) : CliTargetParser(name) { val module = modules.first { it.parsed } + val targetCliCommand = TargetCliCommand( + target, + passwordInteractive + ) + return DesktopCliCommand( DesktopType.valueOf(module.name.uppercase()), - TargetCliCommand( - target, - passwordInteractive - ), + targetCliCommand, module.configFileName, module.onlyModules ) diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/configuration/application/CliTargetParserTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/configuration/application/CliTargetParserTest.kt index dee51f2..40f74bb 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/configuration/application/CliTargetParserTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/configuration/application/CliTargetParserTest.kt @@ -1,9 +1,21 @@ package org.domaindrivenarchitecture.provs.configuration.application +import org.domaindrivenarchitecture.provs.configuration.domain.TargetCliCommand import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test + +private fun parseTarget( + args: Array +): TargetCliCommand { + val parser = CliTargetParser("provs") + + parser.parse(args) + + return TargetCliCommand(parser.target, parser.passwordInteractive) +} + internal class CliTargetParserTest { @Test