Skip to content

Commit 58d10d3

Browse files
committed
fix(cli): 统一工作区视图分隔线宽度
1 parent 7954d02 commit 58d10d3

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/cortex-cli/src/workspace_cmd.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ use clap::Parser;
1010
use serde::{Deserialize, Serialize};
1111
use std::path::PathBuf;
1212

13+
const WORKSPACE_SECTION_RULE_WIDTH: usize = 50;
14+
1315
/// Workspace CLI command.
1416
#[derive(Debug, Parser)]
1517
pub struct WorkspaceCli {
@@ -184,15 +186,15 @@ async fn run_show(args: WorkspaceShowArgs) -> Result<()> {
184186
}
185187

186188
println!("Workspace Information");
187-
println!("{}", "=".repeat(50));
189+
println!("{}", "=".repeat(WORKSPACE_SECTION_RULE_WIDTH));
188190
println!(" Root: {}", info.root.display());
189191
if let Some(ref name) = info.project_name {
190192
println!(" Project: {}", name);
191193
}
192194
println!();
193195

194196
println!("Configuration:");
195-
println!("{}", "-".repeat(40));
197+
println!("{}", "-".repeat(WORKSPACE_SECTION_RULE_WIDTH));
196198
println!(
197199
" .cortex/config.toml: {}",
198200
if info.has_cortex_config {
@@ -217,7 +219,7 @@ async fn run_show(args: WorkspaceShowArgs) -> Result<()> {
217219
if let Some(ref settings) = info.settings {
218220
println!();
219221
println!("Workspace Settings:");
220-
println!("{}", "-".repeat(40));
222+
println!("{}", "-".repeat(WORKSPACE_SECTION_RULE_WIDTH));
221223
if let Some(ref model) = settings.model {
222224
println!(" Model: {}", model);
223225
}
@@ -628,6 +630,13 @@ mod tests {
628630
assert!(args.json);
629631
}
630632

633+
#[test]
634+
fn test_workspace_show_rule_width_is_consistent() {
635+
assert_eq!(WORKSPACE_SECTION_RULE_WIDTH, 50);
636+
assert_eq!("=".repeat(WORKSPACE_SECTION_RULE_WIDTH).len(), 50);
637+
assert_eq!("-".repeat(WORKSPACE_SECTION_RULE_WIDTH).len(), 50);
638+
}
639+
631640
// ==========================================================================
632641
// WorkspaceInitArgs tests
633642
// ==========================================================================

0 commit comments

Comments
 (0)