Feature/base directory#3
Conversation
| return | ||
| } | ||
| val file = File(input.first()) | ||
| var scriptfilePath = input.first() |
There was a problem hiding this comment.
The following lines of code have been duplicated several times. I would like to suggest to put the logic for that in a separate helper object that knows how to construct a File object from an input string, respecting the StateHolder's base dir if present.
| input.consume(1) | ||
| parsedInput.actions.add(object : Action { | ||
| override fun run(arguments: Set<ParsedArgument>) { | ||
| StateHolder.state.basedir= "" |
There was a problem hiding this comment.
I think that this has been implemented a little too complicated. If baseDir isn't a dir, then this is an error and should be added to parsedInput.errors accordingly beforehand. This will automatically lead to it being printed the right way which allows for removing the manual settings of the prompt here.
|
|
||
| object StateHolder { | ||
| data class State(var portSet: Boolean = false, var chaosMonkeyProbability: Int = 0, val openAPISpec: OpenAPI = OpenApiMonitor.getPrototype(), val websocketResources: MutableMap<String, WebsocketResource> = mutableMapOf(), val timerTasks: MutableSet<TimerTask> = mutableSetOf(), var resourceCounter: Int = 0) | ||
| data class State(var portSet: Boolean = false, var chaosMonkeyProbability: Int = 0, val openAPISpec: OpenAPI = OpenApiMonitor.getPrototype(), val websocketResources: MutableMap<String, WebsocketResource> = mutableMapOf(), val timerTasks: MutableSet<TimerTask> = mutableSetOf(), var resourceCounter: Int = 0, var basedir: String = ".") |
There was a problem hiding this comment.
In my opinion, baseDir should be initialized with null since the logic above for determining the relative path already handles that as "relative to here".
| object OpenApiHandler : Handler { | ||
| override fun handle(input: Input, parsedInput: ParsedInput) { | ||
| val pathToOpenApiSpec = input.second() | ||
| var pathToOpenApiSpec = input.second() |
| return | ||
| } | ||
| val file = File(input.first()) | ||
| var scriptfilePath = input.first() |
|
|
||
| private fun getRetValFromFile(input: Input, statusCode: Int): DynamicRetVal { | ||
| val file = File(input.second()) | ||
| var returnValueFilePath = input.second() |
No description provided.