-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: support for managing command aliases #4170
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7ceb651
feat(command): persist aliases on rename and apply to runtime filter
ocetars af21ad2
feat(dashboard-api): support aliases in rename command endpoint
ocetars ab9eacd
feat(dashboard-ui): add alias editor to rename command dialog
ocetars a4e13bb
feat(dashboard-ui): enhance alias editor UI in rename dialog
ocetars File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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.
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.
issue (complexity): 建议抽取用于别名规范化和
extra_data访问的共享辅助函数,这样别名处理和过滤器更新的逻辑只在一个地方定义,而不是在多个函数中重复。你可以通过集中处理别名规范化和
extra_data访问,并复用描述符/过滤器的别名路径,来降低新增的复杂度。1. 将别名规范化逻辑集中到一处
目前,同样的逻辑分别出现在
_bind_descriptor_with_config、_apply_config_to_runtime和rename_command(校验步骤)中。可以用一个小的辅助函数把规则集中起来:然后在各处复用它:
这样就可以去掉重复的“转为字符串 / 去空格 / 过滤空字符串 / 只接受列表”逻辑。
2. 为别名抽象
extra_data的访问可以新增一些小的辅助函数,而不是让每个调用点都知道
"resolved_aliases"这个 key:然后在调用处使用:
这样一来,未来如果
extra_data的结构或别名规则发生变化,只需要修改这些辅助函数即可。3. 明确过滤器别名在列表 ↔ 集合之间的转换
descriptor.aliases和extra_data["resolved_aliases"]使用的是列表,而过滤器期望的是set。可以把这层转换封装到_set_filter_aliases中,这样调用点就不需要关心差异:结合
_get_resolved_aliases,这可以让描述符/过滤器的逻辑路径保持一致,并且把“为什么这里用 set 而不是 list”这类细节集中到一个地方管理。Original comment in English
issue (complexity): Consider extracting shared helpers for alias normalization and extra_data access so alias handling and filter updates are defined once instead of repeated in multiple functions.
You can reduce the new complexity by centralizing alias normalization and
extra_dataaccess, and by sharing the descriptor/filter alias paths.1. Centralize alias normalization
Right now the same logic appears in
_bind_descriptor_with_config,_apply_config_to_runtime, andrename_command(validation step). A small helper keeps the rules in one place:Then reuse it:
This removes repeated “cast to str / strip / non-empty / list-only” logic.
2. Abstract
extra_dataaccess for aliasesInstead of each call site knowing about
"resolved_aliases", add tiny helpers:Then:
Now future changes to
extra_datashape or alias rules only touch these helpers.3. Clarify list ↔ set conversion for filter aliases
descriptor.aliasesandextra_data["resolved_aliases"]are lists, while the filter expects aset. Wrap this in_set_filter_aliasesso call sites don’t worry about the difference:Combined with
_get_resolved_aliases, this makes the descriptor/filter paths consistent and keeps the “why set vs list” detail in one place.