Skip to content

Commit a0cfd81

Browse files
committed
Cargo fmt
1 parent 66ec737 commit a0cfd81

File tree

93 files changed

+1525
-1091
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1525
-1091
lines changed

helix-cli/src/commands/add.rs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,20 @@ pub async fn run(deployment_type: CloudDeploymentTypeCommand) -> Result<()> {
4242
let helix_manager = HelixManager::new(&project_context);
4343

4444
// Create cloud instance configuration
45-
let cloud_config = helix_manager.create_instance_config(&instance_name, region).await?;
45+
let cloud_config = helix_manager
46+
.create_instance_config(&instance_name, region)
47+
.await?;
4648

4749
// Initialize the cloud cluster
48-
helix_manager.init_cluster(&instance_name, &cloud_config).await?;
50+
helix_manager
51+
.init_cluster(&instance_name, &cloud_config)
52+
.await?;
4953

5054
// Insert into project configuration
51-
project_context
52-
.config
53-
.cloud
54-
.insert(instance_name.clone(), CloudConfig::Helix(cloud_config.clone()));
55+
project_context.config.cloud.insert(
56+
instance_name.clone(),
57+
CloudConfig::Helix(cloud_config.clone()),
58+
);
5559

5660
print_status("CLOUD", "Helix cloud instance configuration added");
5761
}
@@ -70,7 +74,9 @@ pub async fn run(deployment_type: CloudDeploymentTypeCommand) -> Result<()> {
7074
.await?;
7175

7276
// Initialize the ECR repository
73-
ecr_manager.init_repository(&instance_name, &ecr_config).await?;
77+
ecr_manager
78+
.init_repository(&instance_name, &ecr_config)
79+
.await?;
7480

7581
// Save configuration to ecr.toml
7682
ecr_manager.save_config(&instance_name, &ecr_config).await?;
@@ -110,12 +116,14 @@ pub async fn run(deployment_type: CloudDeploymentTypeCommand) -> Result<()> {
110116
);
111117

112118
// Initialize the Fly.io app
113-
fly_manager.init_app(&instance_name, &instance_config).await?;
119+
fly_manager
120+
.init_app(&instance_name, &instance_config)
121+
.await?;
114122

115-
project_context
116-
.config
117-
.cloud
118-
.insert(instance_name.clone(), CloudConfig::FlyIo(instance_config.clone()));
123+
project_context.config.cloud.insert(
124+
instance_name.clone(),
125+
CloudConfig::FlyIo(instance_config.clone()),
126+
);
119127
}
120128
_ => {
121129
// Add local instance with default configuration

helix-cli/src/commands/build.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,19 @@ fn needs_cache_recreation(repo_cache: &std::path::Path) -> Result<bool> {
119119

120120
match (DEV_MODE, is_git_repo) {
121121
(true, true) => {
122-
print_status("CACHE", "Cache is git repo but DEV_MODE requires copy - recreating...");
122+
print_status(
123+
"CACHE",
124+
"Cache is git repo but DEV_MODE requires copy - recreating...",
125+
);
123126
Ok(true)
124-
},
127+
}
125128
(false, false) => {
126-
print_status("CACHE", "Cache is copy but production mode requires git repo - recreating...");
129+
print_status(
130+
"CACHE",
131+
"Cache is copy but production mode requires git repo - recreating...",
132+
);
127133
Ok(true)
128-
},
134+
}
129135
_ => Ok(false),
130136
}
131137
}

helix-cli/src/commands/check.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ async fn check_all_instances(project: &ProjectContext) -> Result<()> {
4646
Ok(())
4747
}
4848

49-
50-
5149
/// Validate project syntax by parsing queries and schema (similar to build.rs but without generating files)
5250
fn validate_project_syntax(project: &ProjectContext) -> Result<()> {
5351
print_status("VALIDATE", "Parsing and validating Helix queries");

helix-cli/src/commands/integrations/ecr.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ impl<'a> EcrManager<'a> {
9292
format!("helix-{}-{instance_name}", self.project.config.project.name)
9393
}
9494

95-
9695
fn image_name(&self, repository_name: &str, build_mode: BuildMode) -> String {
9796
let tag = match build_mode {
9897
BuildMode::Debug => "debug",

helix-cli/src/commands/metrics.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ async fn show_metrics_status() -> Result<()> {
9090
Ok(())
9191
}
9292

93-
static EMAIL_REGEX: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$").unwrap());
93+
static EMAIL_REGEX: LazyLock<Regex> =
94+
LazyLock::new(|| Regex::new(r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$").unwrap());
9495

9596
fn ask_for_email() -> String {
9697
print_line("Please enter your email address:");

helix-cli/src/commands/migrate.rs

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,10 @@ fn find_hx_files(project_dir: &Path) -> Result<Vec<PathBuf>> {
231231
let entry = entry?;
232232
let path = entry.path();
233233

234-
if let Some(extension) = path.extension() && extension == "hx" && path.file_name() != Some("schema.hx".as_ref()) {
234+
if let Some(extension) = path.extension()
235+
&& extension == "hx"
236+
&& path.file_name() != Some("schema.hx".as_ref())
237+
{
235238
hx_files.push(path);
236239
}
237240
}
@@ -274,18 +277,28 @@ fn show_migration_plan(ctx: &MigrationContext) -> Result<()> {
274277

275278
print_newline();
276279
print_header("🏠 Home Directory Migration:");
277-
let home_dir = dirs::home_dir().ok_or_else(|| CliError::new("Could not find home directory"))?;
280+
let home_dir =
281+
dirs::home_dir().ok_or_else(|| CliError::new("Could not find home directory"))?;
278282
let v1_helix_dir = home_dir.join(".helix");
279283
if v1_helix_dir.exists() {
280284
let v2_marker = v1_helix_dir.join(".v2");
281285
if v2_marker.exists() {
282-
print_field("Already migrated", "~/.helix directory already migrated to v2");
286+
print_field(
287+
"Already migrated",
288+
"~/.helix directory already migrated to v2",
289+
);
283290
} else {
284291
print_field("Create backup", "~/.helix → ~/.helix-v1-backup");
285292
if v1_helix_dir.join("dockerdev").exists() {
286-
print_field("Clean up Docker", "Stop/remove helix-dockerdev containers and images");
293+
print_field(
294+
"Clean up Docker",
295+
"Stop/remove helix-dockerdev containers and images",
296+
);
287297
}
288-
print_field("Clean directory", "Remove all except ~/.helix/credentials and ~/.helix/repo");
298+
print_field(
299+
"Clean directory",
300+
"Remove all except ~/.helix/credentials and ~/.helix/repo",
301+
);
289302
if v1_helix_dir.join("credentials").exists() {
290303
print_field("Preserve file", "~/.helix/credentials");
291304
}
@@ -497,9 +510,8 @@ fn provide_post_migration_guidance(ctx: &MigrationContext) -> Result<()> {
497510
fn migrate_home_directory(_ctx: &MigrationContext) -> Result<()> {
498511
print_status("HOME", "Migrating ~/.helix directory");
499512

500-
let home_dir = dirs::home_dir().ok_or_else(|| {
501-
CliError::new("Could not find home directory")
502-
})?;
513+
let home_dir =
514+
dirs::home_dir().ok_or_else(|| CliError::new("Could not find home directory"))?;
503515

504516
let v1_helix_dir = home_dir.join(".helix");
505517

@@ -526,8 +538,7 @@ fn migrate_home_directory(_ctx: &MigrationContext) -> Result<()> {
526538

527539
// Use the utility function to copy the directory without exclusions
528540
crate::utils::copy_dir_recursively(&v1_helix_dir, &backup_dir).map_err(|e| {
529-
CliError::new("Failed to backup ~/.helix directory")
530-
.with_caused_by(e.to_string())
541+
CliError::new("Failed to backup ~/.helix directory").with_caused_by(e.to_string())
531542
})?;
532543

533544
print_success("Created backup: ~/.helix-v1-backup");
@@ -546,8 +557,7 @@ fn migrate_home_directory(_ctx: &MigrationContext) -> Result<()> {
546557
let temp_credentials = if credentials_path.exists() {
547558
let temp_path = home_dir.join(".helix-credentials-temp");
548559
fs::rename(&credentials_path, &temp_path).map_err(|e| {
549-
CliError::new("Failed to backup credentials")
550-
.with_caused_by(e.to_string())
560+
CliError::new("Failed to backup credentials").with_caused_by(e.to_string())
551561
})?;
552562
Some(temp_path)
553563
} else {
@@ -556,48 +566,40 @@ fn migrate_home_directory(_ctx: &MigrationContext) -> Result<()> {
556566

557567
let temp_repo = if repo_path.exists() {
558568
let temp_path = home_dir.join(".helix-repo-temp");
559-
fs::rename(&repo_path, &temp_path).map_err(|e| {
560-
CliError::new("Failed to backup repo")
561-
.with_caused_by(e.to_string())
562-
})?;
569+
fs::rename(&repo_path, &temp_path)
570+
.map_err(|e| CliError::new("Failed to backup repo").with_caused_by(e.to_string()))?;
563571
Some(temp_path)
564572
} else {
565573
None
566574
};
567575

568576
// Remove the entire .helix directory
569577
fs::remove_dir_all(&v1_helix_dir).map_err(|e| {
570-
CliError::new("Failed to remove ~/.helix directory")
571-
.with_caused_by(e.to_string())
578+
CliError::new("Failed to remove ~/.helix directory").with_caused_by(e.to_string())
572579
})?;
573580

574581
// Recreate .helix directory
575582
fs::create_dir_all(&v1_helix_dir).map_err(|e| {
576-
CliError::new("Failed to recreate ~/.helix directory")
577-
.with_caused_by(e.to_string())
583+
CliError::new("Failed to recreate ~/.helix directory").with_caused_by(e.to_string())
578584
})?;
579585

580586
// Restore credentials and repo
581587
if let Some(temp_creds) = temp_credentials {
582588
fs::rename(&temp_creds, &credentials_path).map_err(|e| {
583-
CliError::new("Failed to restore credentials")
584-
.with_caused_by(e.to_string())
589+
CliError::new("Failed to restore credentials").with_caused_by(e.to_string())
585590
})?;
586591
print_info("Preserved ~/.helix/credentials");
587592
}
588593

589594
if let Some(temp_repo) = temp_repo {
590-
fs::rename(&temp_repo, &repo_path).map_err(|e| {
591-
CliError::new("Failed to restore repo")
592-
.with_caused_by(e.to_string())
593-
})?;
595+
fs::rename(&temp_repo, &repo_path)
596+
.map_err(|e| CliError::new("Failed to restore repo").with_caused_by(e.to_string()))?;
594597
print_info("Preserved ~/.helix/repo");
595598
}
596599

597600
// Create .v2 marker file to indicate migration is complete
598601
fs::write(&v2_marker, "").map_err(|e| {
599-
CliError::new("Failed to create v2 marker file")
600-
.with_caused_by(e.to_string())
602+
CliError::new("Failed to create v2 marker file").with_caused_by(e.to_string())
601603
})?;
602604

603605
print_success("Cleaned up ~/.helix directory, preserving credentials and repo");
@@ -622,7 +624,13 @@ fn cleanup_dockerdev() -> Result<()> {
622624

623625
// Try to remove any helix-related images
624626
let output = std::process::Command::new("docker")
625-
.args(["images", "--format", "{{.Repository}}:{{.Tag}}", "--filter", "reference=helix*"])
627+
.args([
628+
"images",
629+
"--format",
630+
"{{.Repository}}:{{.Tag}}",
631+
"--filter",
632+
"reference=helix*",
633+
])
626634
.output();
627635

628636
if let Ok(output) = output {
@@ -636,7 +644,14 @@ fn cleanup_dockerdev() -> Result<()> {
636644

637645
// Try to remove helix volumes
638646
let output = std::process::Command::new("docker")
639-
.args(["volume", "ls", "--format", "{{.Name}}", "--filter", "name=helix"])
647+
.args([
648+
"volume",
649+
"ls",
650+
"--format",
651+
"{{.Name}}",
652+
"--filter",
653+
"name=helix",
654+
])
640655
.output();
641656

642657
if let Ok(output) = output {

helix-cli/src/commands/prune.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,27 @@ async fn prune_all_instances(project: &ProjectContext) -> Result<()> {
7171
return Ok(());
7272
}
7373

74-
print_status("PRUNE", &format!("Found {} instance(s) to prune", instances.len()));
74+
print_status(
75+
"PRUNE",
76+
&format!("Found {} instance(s) to prune", instances.len()),
77+
);
7578

7679
if DockerManager::check_docker_available().is_ok() {
7780
let docker = DockerManager::new(project);
7881

7982
for instance_name in &instances {
80-
print_status("PRUNE", &format!("Removing containers for '{instance_name}'"));
83+
print_status(
84+
"PRUNE",
85+
&format!("Removing containers for '{instance_name}'"),
86+
);
8187

8288
// Remove containers (but not volumes)
8389
let _ = docker.prune_instance(instance_name, false);
8490

85-
print_status("PRUNE", &format!("Removing Docker images for '{instance_name}'"));
91+
print_status(
92+
"PRUNE",
93+
&format!("Removing Docker images for '{instance_name}'"),
94+
);
8695
// Remove Docker images
8796
let _ = docker.remove_instance_images(instance_name);
8897
}
@@ -93,8 +102,12 @@ async fn prune_all_instances(project: &ProjectContext) -> Result<()> {
93102
let workspace = project.instance_workspace(instance_name);
94103
if workspace.exists() {
95104
match std::fs::remove_dir_all(&workspace) {
96-
Ok(()) => print_status("PRUNE", &format!("Removed workspace for '{instance_name}'")),
97-
Err(e) => print_warning(&format!("Failed to remove workspace for '{instance_name}': {e}")),
105+
Ok(()) => {
106+
print_status("PRUNE", &format!("Removed workspace for '{instance_name}'"))
107+
}
108+
Err(e) => print_warning(&format!(
109+
"Failed to remove workspace for '{instance_name}': {e}"
110+
)),
98111
}
99112
}
100113
}

helix-cli/src/commands/start.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ async fn start_local_instance(project: &ProjectContext, instance_name: &str) ->
3535
let compose_file = workspace.join("docker-compose.yml");
3636

3737
if !compose_file.exists() {
38-
let error = crate::errors::CliError::new(format!("instance '{instance_name}' has not been built yet"))
39-
.with_hint(format!("run 'helix build {instance_name}' first to build the instance"));
38+
let error = crate::errors::CliError::new(format!(
39+
"instance '{instance_name}' has not been built yet"
40+
))
41+
.with_hint(format!(
42+
"run 'helix build {instance_name}' first to build the instance"
43+
));
4044
return Err(eyre::eyre!("{}", error.render()));
4145
}
4246

helix-cli/src/errors.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ impl CliError {
9292
self
9393
}
9494

95-
9695
pub fn render(&self) -> String {
9796
let mut output = String::new();
9897

@@ -186,36 +185,30 @@ pub type CliResult<T> = Result<T, CliError>;
186185
// Convenience functions for common error patterns with error codes
187186
#[allow(unused)]
188187
pub fn config_error<S: Into<String>>(message: S) -> CliError {
189-
CliError::new(message)
190-
.with_hint("run `helix init` if you need to create a new project")
188+
CliError::new(message).with_hint("run `helix init` if you need to create a new project")
191189
}
192190

193191
#[allow(unused)]
194192
pub fn file_error<S: Into<String>>(message: S, file_path: S) -> CliError {
195-
CliError::new(message)
196-
.with_file_path(file_path)
193+
CliError::new(message).with_file_path(file_path)
197194
}
198195

199196
#[allow(unused)]
200197
pub fn docker_error<S: Into<String>>(message: S) -> CliError {
201-
CliError::new(message)
202-
.with_hint("ensure Docker is running and accessible")
198+
CliError::new(message).with_hint("ensure Docker is running and accessible")
203199
}
204200

205201
#[allow(unused)]
206202
pub fn network_error<S: Into<String>>(message: S) -> CliError {
207-
CliError::new(message)
208-
.with_hint("check your internet connection and try again")
203+
CliError::new(message).with_hint("check your internet connection and try again")
209204
}
210205

211206
#[allow(unused)]
212207
pub fn project_error<S: Into<String>>(message: S) -> CliError {
213-
CliError::new(message)
214-
.with_hint("ensure you're in a valid helix project directory")
208+
CliError::new(message).with_hint("ensure you're in a valid helix project directory")
215209
}
216210

217211
#[allow(unused)]
218212
pub fn cloud_error<S: Into<String>>(message: S) -> CliError {
219-
CliError::new(message)
220-
.with_hint("run `helix auth login` to authenticate with Helix Cloud")
213+
CliError::new(message).with_hint("run `helix auth login` to authenticate with Helix Cloud")
221214
}

helix-cli/src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ async fn main() -> Result<()> {
203203
port,
204204
dry_run,
205205
no_backup,
206-
} => commands::migrate::run(path, queries_dir, instance_name, port, dry_run, no_backup).await,
206+
} => {
207+
commands::migrate::run(path, queries_dir, instance_name, port, dry_run, no_backup).await
208+
}
207209
};
208210

209211
// Shutdown metrics sender

0 commit comments

Comments
 (0)