-
Notifications
You must be signed in to change notification settings - Fork 35
style: add visual divider between folders and items in workspace listing #165
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: main
Are you sure you want to change the base?
Changes from all commits
36520e2
444d351
8b34e28
0c47fda
ccd7b91
43cc353
ea76426
c702b91
5e847ef
69c733e
5d5f1ad
0c5de9c
025f456
df0c5a4
c6892ed
f30ce9b
cf7e06b
3a727dd
d3cfbb4
bb051b1
f46f685
19e3a75
55020f0
0c08fb5
beb0149
c0e3672
ca313c3
8aa05e7
39f2d85
5e3b68e
7c573b0
f9a4bb2
f04c7b7
641c4e7
516dbb8
484993f
3a42a5c
0755733
5917da7
635eadc
22cc9cb
44f44b3
ec97f25
1ffb863
74f9410
95306b8
d1df1f3
673ee80
71b11fa
66eaf93
7eac2c5
5d647dc
5c455ce
1adf434
5897cde
845fcb5
5278b73
3c75e88
326c429
aca8824
c2ac8ba
2dc9582
7b9fc69
31fe14a
f567fad
93a8170
d60e42c
49e143b
ea026ef
89285fb
e80c8bb
2da449f
b5580f2
5f4e7fe
73166a5
269107f
43b04df
4eaca2c
4ff4f18
692e5d6
63e61f1
9dc7758
e2d5a0d
0c9cfa2
c06933c
980b4da
a73b480
d1d5dc2
4005a96
31c17c1
aa82800
8a026ed
a4a7de2
28403cc
2a42459
ed802ec
75b7bf4
419ef59
60991e9
1bd6b5c
bc9c6e7
3afe8aa
53007dc
8ede310
e4db571
0d7cff1
ff2aa75
0014433
4abc444
24babb6
642d10a
1b3ad3f
e5cf283
be6a304
e757824
869bb6b
8f4ba23
fa70568
f57416a
c18c8d3
98fa381
3aa4235
7e453d6
097e44f
aaf4c0a
b5fda27
c4d2625
22534b7
8218321
8f48c54
42d8e88
d874933
9b087b7
ca2e8af
6d6995e
0d2f72e
8c835a3
c9d4333
6832504
5d07d94
f33129e
c1cbad8
8c7fc37
a80d9ce
e88d7dc
7061a0e
ba8a91f
29842da
e1b9de1
b6b32ef
1df36d1
a54718d
54f76b0
5450d36
de23330
2db59e0
c543b3d
6cf16f1
fc662ec
de4d51c
9cc9098
8c3acaf
8f34833
0aaa4e9
26f7921
b64c032
d70089f
7b13492
2deaefd
58f421e
e9bd691
632dac0
3bf5ac9
556b7d8
ebc4bfd
1b78129
6048a29
c245e60
fadeb93
d19fb66
155acba
155991b
94fe862
f8307a2
5852e12
e8400a3
8419b52
3d871ec
36ac241
4678bbd
2ff6ce8
4e23ee1
4ef6c53
dd8ccac
f3108ec
06d3d82
56be8f3
c5590ef
2fe7bdc
42315db
e5acd35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| kind: optimization | ||
| body: Add visual divider between folders and items in `ls` command on workspaces with text output format | ||
| time: 2026-02-03T16:34:40.477661885Z | ||
| custom: | ||
| Author: ayeshurun | ||
| AuthorLink: https://github.com/ayeshurun |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,12 +10,68 @@ | |
| from fabric_cli.utils import fab_cmd_fs_utils as utils_fs | ||
| from fabric_cli.utils import fab_cmd_ls_utils as utils_ls | ||
|
|
||
| # Divider used to separate folders and items in workspace listings | ||
| _DIVIDER = "------------------------------" | ||
|
|
||
|
|
||
| def _sort_ws_elements_with_seperation( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not adding the separator in get_ws_elements? we already filter there the folders and items... so we could add there the login |
||
| ws_elements: list[Union[Item, Folder]], show_details: bool | ||
| ) -> list[dict]: | ||
| """ | ||
| Groups elements by type (Folders first, then Items), sorts each group using sort_ws_elements, | ||
| and inserts a divider between non-empty groups. | ||
|
|
||
| Args: | ||
| ws_elements: List of workspace elements (Items and Folders) | ||
| show_details: Whether to include detailed columns | ||
|
|
||
| Returns: | ||
| list: Single list with folders first, divider, then items | ||
| """ | ||
| if not ws_elements: | ||
| return [] | ||
|
|
||
| result = [] | ||
| first_group = True | ||
| type_order = [Folder, Item] | ||
|
|
||
| for typ in type_order: | ||
| group = [el for el in ws_elements if isinstance(el, typ)] | ||
| if group: | ||
| group_dicts = utils_fs.sort_ws_elements(group, show_details) | ||
| if not first_group: | ||
| divider = {"name": _DIVIDER} | ||
| if show_details: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. didn't show_details is always false? if folder_listing_enabled and output_format == "text" and not show_details: |
||
| divider["id"] = "" | ||
| result.append(divider) | ||
| result.extend(group_dicts) | ||
| first_group = False | ||
|
|
||
| return result | ||
|
|
||
|
|
||
| def exec(workspace: Workspace, args): | ||
| show_details = bool(args.long) | ||
| show_all = bool(args.all) | ||
| ws_elements: list[Union[Item, Folder]] = utils_fs.get_ws_elements(workspace) | ||
| sorted_elements_dict = utils_fs.sort_ws_elements(ws_elements, show_details) | ||
|
|
||
| # Check if folder listing is enabled | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pls remove redundant comment - same for other comments bellow |
||
| folder_listing_enabled = ( | ||
| fab_state_config.get_config(fab_constant.FAB_FOLDER_LISTING_ENABLED) == "true" | ||
| ) | ||
|
|
||
| # Get output format from args or config | ||
| output_format = getattr(args, "output_format", None) or fab_state_config.get_config( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. output_format should not be used here - only in fab_ui |
||
| fab_constant.FAB_OUTPUT_FORMAT | ||
| ) | ||
|
|
||
| # Use separation if folder listing is enabled, output is text format, and --long is not provided | ||
| if folder_listing_enabled and output_format == "text" and not show_details: | ||
| sorted_elements_dict = _sort_ws_elements_with_seperation( | ||
| ws_elements, show_details | ||
| ) | ||
| else: | ||
| sorted_elements_dict = utils_fs.sort_ws_elements(ws_elements, show_details) | ||
|
|
||
| show_hidden = ( | ||
| show_all or fab_state_config.get_config(fab_constant.FAB_SHOW_HIDDEN) == "true" | ||
|
|
@@ -25,6 +81,6 @@ def exec(workspace: Workspace, args): | |
| data=sorted_elements_dict, | ||
| args=args, | ||
| show_details=show_details, | ||
| columns=sorted_elements_dict[0].keys() if sorted_elements_dict else [], | ||
| columns=list(sorted_elements_dict[0].keys()) if sorted_elements_dict else [], | ||
| hidden_data=VirtualItemContainerType if show_hidden else None, | ||
| ) | ||
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.
we have this logic in fab_ui when hidden_data is true - why not enhance this logic? it will resolve also the use of output_format in ls command