Conversation
ArtyomLobanov
suggested changes
Mar 14, 2019
ArtyomLobanov
left a comment
There was a problem hiding this comment.
И заберите изменения из ветки bash, пожалуйста. А то без cat, например, грустно
| input.forEachLine { | ||
| val matchString = if (args.ignoreCase) it.toLowerCase() else it | ||
| val matchPattern = if (args.ignoreCase) args.pattern.toLowerCase() else args.pattern | ||
| val wordEnd = if (args.wordRegexp) "(\\s|^|\$)" else "" |
There was a problem hiding this comment.
Для обозначения концов слова (в человеческом смысле) есть \b. Стандартный grep с ключом -w позволяет матчить слово мир в тексте Привет, мир!, несмотря на знак препинания !.
| private fun grep(input: Reader, output: PipedWriter, args: PipedGrepArgs) { | ||
| var linesToWrite = 0; | ||
| input.forEachLine { | ||
| val matchString = if (args.ignoreCase) it.toLowerCase() else it |
| try { | ||
| return ArgParser(arr).parseInto(constructor) | ||
| } catch (e: ShowHelpException) { | ||
| println(e.printUserMessage(output, "grep", 80)) |
There was a problem hiding this comment.
Не надо писать в стандартный поток вывода из глубины проекта. Способ общения с пользователем может ещё 100 раз поменяться. Бросайте исключения
Owner
Author
There was a problem hiding this comment.
Я не очень понял, почему там вообще println написан, он просто Unit печатает, убрал
# Conflicts: # bash/build.gradle # bash/src/main/kotlin/hse/nedikov/bash/logic/commands/Echo.kt
|
Теперь тесты падают :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Я рассмотрел 3 варианта библиотек:
Выбрал вторую, теперь комментарии почему:
Есть ещё JCommander, но на Котлине лучше, по возможности, использовать библиотеки Котлина, чтобы не костылять с джавовской совместимостью, а пользоваться сразу адаптированной библиотекой с кучей синтаксических плюшек.