Merged
Conversation
Contributor
There was a problem hiding this comment.
Hey - 我发现了 1 个问题
给 AI Agent 的提示
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src-tauri/src/commands/system.rs" line_range="541-550" />
<code_context>
+/// 获取命令行 -i/--instance 参数指定的启动实例名称
+#[tauri::command]
+pub fn get_start_instance() -> Option<String> {
+ let args: Vec<String> = std::env::args().collect();
+ let mut iter = args.iter();
+ while let Some(arg) = iter.next() {
+ if arg == "-i" || arg == "--instance" {
+ return iter.next().cloned();
+ }
+ if let Some(value) = arg.strip_prefix("-i=") {
+ return Some(value.to_string());
+ }
+ if let Some(value) = arg.strip_prefix("--instance=") {
+ return Some(value.to_string());
+ }
+ }
+ None
+}
+
</code_context>
<issue_to_address>
**question:** 请阐明在存在多个 `-i/--instance` 标志,或标志缺少值时的行为。
当前函数会返回它遇到的第一个 `-i/--instance`,并且不做校验地将下一个 token 当作其值,即便这个 token 本身是以 `-` 开头的。这样一来,当存在多个 `-i` 标志或值缺失(例如:`-i -v`)时,可能会在没有任何提示的情况下产生出乎意料的结果。建议要么校验该值不像是另一个标志(例如:拒绝或忽略以 `-` 开头的值),要么对多次出现的情况定义一个明确规则(例如:第一次出现优先或最后一次出现优先),并在实现中严格遵守并在文档中说明。
</issue_to_address>帮我变得更有用!请对每条评论点 👍 或 👎,我会根据反馈改进后续的代码审查。
Original comment in English
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src-tauri/src/commands/system.rs" line_range="541-550" />
<code_context>
+/// 获取命令行 -i/--instance 参数指定的启动实例名称
+#[tauri::command]
+pub fn get_start_instance() -> Option<String> {
+ let args: Vec<String> = std::env::args().collect();
+ let mut iter = args.iter();
+ while let Some(arg) = iter.next() {
+ if arg == "-i" || arg == "--instance" {
+ return iter.next().cloned();
+ }
+ if let Some(value) = arg.strip_prefix("-i=") {
+ return Some(value.to_string());
+ }
+ if let Some(value) = arg.strip_prefix("--instance=") {
+ return Some(value.to_string());
+ }
+ }
+ None
+}
+
</code_context>
<issue_to_address>
**question:** Clarify behavior when multiple `-i/--instance` flags are present or when the flag is missing a value.
Right now, the function returns the first `-i/--instance` it sees and blindly uses the next token as the value, even if it starts with `-`. That means multiple `-i` flags or a missing value (e.g., `-i -v`) can silently produce surprising results. Consider either validating that the value doesn’t look like another flag (e.g., reject or ignore values starting with `-`), or defining a clear rule for multiple occurrences (e.g., first wins vs last wins) and enforcing/documenting it.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
MistEO
reviewed
Apr 2, 2026
src-tauri/src/commands/system.rs
Outdated
Comment on lines
+563
to
+573
| /// 获取命令行 -c/--controller 参数指定的控制器名称 | ||
| #[tauri::command] | ||
| pub fn get_controller_override() -> Option<String> { | ||
| get_cli_arg_value("-c", "--controller") | ||
| } | ||
|
|
||
| /// 检查命令行是否包含 -k/--kill 参数(任务完成后关闭自身) | ||
| #[tauri::command] | ||
| pub fn has_close_flag() -> bool { | ||
| std::env::args().any(|arg| arg == "-k" || arg == "--kill") | ||
| } |
Contributor
Author
There was a problem hiding this comment.
kill参数我觉得是必要的,因为如果是人工操作可以手动关闭游戏,或者之后加些手动操作(比如送快递)。运行同一个配置组的时候不希望跑完就自动关。
Owner
|
kill 名字有点怪,感觉换个名字好一点 |
- 将 -k/--kill 重命名为 -q/--quit-after-run,语义更明确 - 为 get_cli_arg_value 补回 -x=value 和 --name=value 格式支持(重构时遗漏) - 统一 Rust 端函数名、注释和前端日志文本 Made-with: Cursor
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary by Sourcery
通过新增命令行参数来支持选择要自动启动的实例,并将其集成到应用的自动启动流程中。
新功能:
-i/--instanceCLI 参数。Original summary in English
Summary by Sourcery
Support selecting which instance to auto-start via a new command-line argument and integrate it into the app's autostart flow.
New Features: