Skip to content

Enhance source command with enable/disable and improved list display#39

Merged
Yangmoooo merged 6 commits intomainfrom
claude/enhance-source-command
Mar 13, 2026
Merged

Enhance source command with enable/disable and improved list display#39
Yangmoooo merged 6 commits intomainfrom
claude/enhance-source-command

Conversation

@Claude
Copy link
Copy Markdown
Contributor

@Claude Claude AI commented Mar 12, 2026

  • Add source enable/disable commands
  • Enhance source list display (last update time, local + remote sources, --check-remote flag)
  • Add enabled field to UpstreamDef in config
  • Respect enabled flag in Registry::load()
  • Simplify UpstreamDef.enabled field - remove #[serde(default = "default_enabled")] and the helper function, use a plain field (per feedback: project is not stable yet, backward compat overhead not needed)
Original prompt

This section details on the original issue you should resolve

<issue_title>Enhance the source command</issue_title>
<issue_description>### Goal

Optimize the existing source list command experience.

Add source enable/disable commands for registry management.

Proposed Solution

  1. Make the source list command display the last update time by default, and add a --check-remote parameter for verification with remote registries.

  2. Enable the source list command to display both remote and local registries simultaneously. Now show remote only.

  3. Add source enable/disable commands to enable/disable specified registry and display their status in the source list.
    </issue_description>

Comments on the Issue (you are @claude[agent] in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- Add enabled/disabled field to UpstreamDef
- Implement source enable/disable commands
- Show last update time in source list
- Add --check-remote flag to verify with remote registries
- Display both remote and local registries in source list
- Skip disabled sources during update and registry loading

Co-authored-by: Yangmoooo <72434870+Yangmoooo@users.noreply.github.com>
@Claude Claude AI changed the title [WIP] Optimize source list command experience and add registry management Enhance source command with enable/disable and improved list display Mar 12, 2026
@Claude Claude AI requested a review from Yangmoooo March 12, 2026 17:26
@Yangmoooo
Copy link
Copy Markdown
Owner

@copilot 为什么这里在添加upstreamdef的enabled字段时,要单独设置一个函数?在default方法里指定还不够吗

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 13, 2026

@copilot 为什么这里在添加upstreamdef的enabled字段时,要单独设置一个函数?在default方法里指定还不够吗

这里需要单独定义 default_enabled() 函数,而不是只在 Default 实现里设置,原因是它们解决的是不同的场景:

serde 反序列化时的字段缺失处理#[serde(default = "default_enabled")] 用于当用户的 config.tomlUpstreamDef 条目没有 enabled 字段时(比如旧版本的配置文件),serde 需要知道用什么值填充。这个属性要求指定一个函数引用,因为它在反序列化时按需调用。

为什么不能用 #[serde(default)]boolDefault::default() 返回的是 false,而我们需要的默认值是 true。直接用 #[serde(default)] 会导致旧配置文件中没有 enabled 字段的源被误判为已禁用。

Config::default() 里设置的局限:只有在完全没有配置文件时才会走 Config::default()。对于已有配置文件但缺少 enabled 字段的用户,serde 解析时需要字段级别的 default 函数。

这是 Rust serde 中处理"新增字段向后兼容"的标准模式。

@Yangmoooo Yangmoooo marked this pull request as ready for review March 13, 2026 08:24
Copilot AI review requested due to automatic review settings March 13, 2026 08:24
@Yangmoooo Yangmoooo merged commit a4313a0 into main Mar 13, 2026
5 checks passed
@Yangmoooo Yangmoooo deleted the claude/enhance-source-command branch March 13, 2026 08:25
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enhances the inro source command suite to support source enable/disable management and improves source list output to show both remote and local registries, including last-update times and optional remote update checks.

Changes:

  • Add source enable / source disable subcommands and persist the enabled state in config.
  • Enhance source list to display remote + local sources, last update time, and --check-remote.
  • Make registry loading respect the enabled flag when merging upstream registry TOMLs.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/registry.rs Filters upstream registry merges to only enabled sources from config.
src/config.rs Adds enabled: bool to UpstreamDef (with serde default) and updates defaults.
src/commands/source.rs Implements improved source list, skips disabled sources on update, adds enable/disable logic, and remote update checking.
src/cli.rs Extends CLI to accept source list --check-remote and new enable/disable subcommands.
config.example.toml Updates example upstream definition to show enabled = false.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/commands/source.rs
Comment on lines +260 to +262
if !config_path.exists() {
return Err(anyhow!("Config file not found. Please run 'inro source update' first."));
}
Comment thread src/commands/source.rs
Comment on lines +75 to +96
if *check_remote {
match check_remote_update(&upstream.url, &cached_path) {
Ok(true) => {
let s = format!("{} (update available)", time_str);
let d = s.as_str().yellow();
(s, d)
}
Ok(false) => {
let s = format!("{} (up-to-date)", time_str);
let d = s.as_str().green();
(s, d)
}
Err(_) => {
let s = format!("{} (check failed)", time_str);
let d = s.as_str().red();
(s, d)
}
}
} else {
let d = time_str.as_str().normal();
(time_str, d)
}
Comment thread src/registry.rs
Comment on lines +28 to +38
let enabled_names: HashSet<String> = config
.upstreams
.iter()
.filter(|u| u.enabled)
.map(|u| format!("{:02}-{}.toml", u.priority, u.name))
.collect();
let mut upstream_files = collect_toml_files(upstream_registry_dir)?;
upstream_files.retain(|p| {
p.file_name()
.and_then(|n| n.to_str())
.map(|n| enabled_names.contains(n))
Comment thread src/config.rs
Comment on lines +34 to +38
#[serde(default = "default_enabled")]
pub enabled: bool,
}

fn default_enabled() -> bool { true }
Comment thread src/cli.rs
@@ -173,7 +173,25 @@ pub enum SourceSubCommand {

/// List all configured remote sources and their status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhance the source command

4 participants