-
Notifications
You must be signed in to change notification settings - Fork 0
Задание 5. Команды cd, ls для чужого cli. #1
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: cli
Are you sure you want to change the base?
Conversation
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.
Надо ещё краткое ревью на архитектуру товарища
cli/cdls_unittest.py
Outdated
|
|
||
| self.cli.process_input('cd ~') | ||
| result = self.cli.process_input('ls cd_ls_test') | ||
| self.assertEqual(result.get_output(), 'dir2\ndir1\n') |
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.
Лучше на несколько тестов разбить
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.
И под виндой не работает из-за переводов строк
| if len(self.args) < 1: | ||
| arg = '~' | ||
| else: | ||
| arg = self.args[0] |
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.
Желательно ещё проверять, что их не больше, чем надо, и сообщать пользователю об ошибке. А то будет как в анекдотах про Linux: rm -rf *.out -> rm -rf * .out
cli/src/commands.py
Outdated
| else: | ||
| head, res = os.path.split(ls_path) | ||
| else: | ||
| res = '"'+ls_path+'" not exists' |
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.
Пробелов не хватает :)
cli/src/commands.py
Outdated
|
|
||
| rv = 0 | ||
| if os.path.isdir(abs_path): | ||
| env.set_cwd(abs_path) |
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.
Неплохо бы нормализовать путь, иначе
> cd ../..
directory "C:\Students\504\CD-LS\pvktk-SD/cli\../.." set
И потом
> pwd
C:\Students\504\CD-LS\pvktk-SD/cli\../..
Так если долго ходить по файловой системе, всё сломается.
Кроссплатформенный перенос строки Нормализация пути Разбиты тесты
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.
Тесты на ls всё равно не работают, там проблема с переносами строк (\r\n vs \n). В остальном же всё ок, так что зачтена
Архитектура, с которой мне пришлось работать, в общем то достаточно удобная. Во все команды передается окружение с текущей рабочей директорией, поэтому изменять достаточно было только его. У команд интерфейс понятный и я достаточно быстро разобрался как дописать свои команды.
Однако мне кажется, что у команд можно было бы сделать по одному методу вместо двух run() и set_args(). Также, возможно, получилось бы избавиться от двойного механизма обработки ошибок (сейчас это исключения и коды возврата).