-
Notifications
You must be signed in to change notification settings - Fork 7
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
Implement formatters for ls operation #469
Conversation
python/neuromation/cli/storage.py
Outdated
|
||
click.echo(StorageLsFormatter()(res)) | ||
for line in layout.format(formatter, files): |
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.
it's generator. We can use click.pager() here instead click.echo()
python/Makefile
Outdated
@@ -10,7 +10,7 @@ ISORT_REGEXP := ^python/(neuromation|tests|build-tools)/.+\\.py | |||
BLACK_DIRS := $(ISORT_DIRS) | |||
BLACK_REGEXP := $(ISORT_REGEXP) | |||
MYPY_DIRS := neuromation | |||
MYPY_REGEXP := ^python/+.\\py | |||
MYPY_REGEXP := ^python/neuromation/+.\\py |
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.
- Why?
- The change is not related to the PR
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.
- It`s right. REGEXP's variables works from project root but DIR's variables from python folder.
- Yes. Can move to separate mini-pr
python/neuromation/cli/storage.py
Outdated
@@ -48,21 +61,232 @@ def storage() -> None: | |||
|
|||
@command() | |||
@click.argument("path", default="storage://~") | |||
@click.option( | |||
"-C", "force_format_vertical", is_flag=True, help="list entries by columns" |
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.
May I ask why did you add all these options?
Where is the corresponding discussion?
#427 mentions only -l
and (indirectly) -h
.
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.
I investigated how work gnu ls and find that it provide 3 formats/layouts according scenarios from #427:
- long, detailed file info, one file per line
- vertical, file names which displayed in few columns and sorted from top-down, left-right. It's deault layout for terminal.
- single-column, file names, one per line. This layout will be enabled automatically when stdout is not terminal and layout is not specified.
Then i learned that we need some more that "-l" switch and add --format option with one additional value commas and next shortcuts: -l, -x, -1, -C, .
After that I consider that commas format often require quoting for file names and add --quote-name(and alias -Q) and inveredt(but default) options --literal(with alias -N)
Also i found that ls sort files by alphabet by default and add --sort option with shortcuts(-f, -S, -t, -U, -r / --reverse).
We haven`t before any time field in ls output but we have modification_time field in FileStatus. As I remember this fields was added some later than neuro storage ls realized, and than this information was missed. I add this information to long format and corresponding options --time-style, --full-time.
There left only one option which not follow initial discussion: --group-directories-first.
That's all.
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.
I think the PR cannot land as is: rare options are not only useless but actually harmful.
They blow documentation size and make learning the tool harder without a strong reason.
Also, it makes the support of existing code harder than needed
Codecov Report
@@ Coverage Diff @@
## master #469 +/- ##
=========================================
+ Coverage 90.61% 90.91% +0.3%
=========================================
Files 36 37 +1
Lines 2439 2553 +114
Branches 282 313 +31
=========================================
+ Hits 2210 2321 +111
- Misses 178 179 +1
- Partials 51 53 +2
Continue to review full report at Codecov.
|
@asvetlov , please check now |
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.
Looks good!
A few comments
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.
LGTM!
Not implemented: