-
Notifications
You must be signed in to change notification settings - Fork 1
done task #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: bash
Are you sure you want to change the base?
Conversation
ArtyomLobanov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
И заберите изменения из ветки 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Для обозначения концов слова (в человеческом смысле) есть \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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| try { | ||
| return ArgParser(arr).parseInto(constructor) | ||
| } catch (e: ShowHelpException) { | ||
| println(e.printUserMessage(output, "grep", 80)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не надо писать в стандартный поток вывода из глубины проекта. Способ общения с пользователем может ещё 100 раз поменяться. Бросайте исключения
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я не очень понял, почему там вообще println написан, он просто Unit печатает, убрал
# Conflicts: # bash/build.gradle # bash/src/main/kotlin/hse/nedikov/bash/logic/commands/Echo.kt
|
Теперь тесты падают :) |
yurii-litvinov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Я рассмотрел 3 варианта библиотек:
Выбрал вторую, теперь комментарии почему:
Есть ещё JCommander, но на Котлине лучше, по возможности, использовать библиотеки Котлина, чтобы не костылять с джавовской совместимостью, а пользоваться сразу адаптированной библиотекой с кучей синтаксических плюшек.