From 3caca0dfcb1e26da87f94e05099ea2a1e7cc691f Mon Sep 17 00:00:00 2001 From: bereck-work Date: Sat, 22 Nov 2025 10:17:28 +0000 Subject: [PATCH] (Fix): Removed unneccessary comments that my copilot generated. --- internal/archiver/compare_test.go | 1 - internal/archiver/zip_test.go | 7 ------- internal/cli/cli.go | 11 +---------- internal/fetcher/fetcher.go | 13 ++----------- internal/ui/autocomplete.go | 8 -------- internal/ui/batch.go | 2 -- internal/ui/compress.go | 5 ----- internal/version/version.go | 2 -- 8 files changed, 3 insertions(+), 46 deletions(-) diff --git a/internal/archiver/compare_test.go b/internal/archiver/compare_test.go index b066099..a132ee6 100644 --- a/internal/archiver/compare_test.go +++ b/internal/archiver/compare_test.go @@ -80,7 +80,6 @@ func TestCompareIdenticalArchives(t *testing.T) { } defer os.RemoveAll(tmpDir) - // Create source directory sourceDir := filepath.Join(tmpDir, "source") os.Mkdir(sourceDir, 0755) os.WriteFile(filepath.Join(sourceDir, "file1.txt"), []byte("content"), 0644) diff --git a/internal/archiver/zip_test.go b/internal/archiver/zip_test.go index 8ae8bda..6c41c03 100644 --- a/internal/archiver/zip_test.go +++ b/internal/archiver/zip_test.go @@ -21,12 +21,10 @@ func TestCreateZip(t *testing.T) { os.WriteFile(filepath.Join(sourceDir, "file1.txt"), []byte("content1"), 0644) os.WriteFile(filepath.Join(sourceDir, "file2.txt"), []byte("content2"), 0644) - // Create subdirectory subDir := filepath.Join(sourceDir, "subdir") os.Mkdir(subDir, 0755) os.WriteFile(filepath.Join(subDir, "file3.txt"), []byte("content3"), 0644) - // Create ZIP zipPath := filepath.Join(tmpDir, "test.zip") config := &models.CompressConfig{ SourcePath: sourceDir, @@ -59,11 +57,9 @@ func TestCreateZipWithCompressionLevels(t *testing.T) { } defer os.RemoveAll(tmpDir) - // Create test file with compressible content sourceDir := filepath.Join(tmpDir, "source") os.Mkdir(sourceDir, 0755) - // Create a file with repetitive content (compresses well) content := make([]byte, 10000) for i := range content { content[i] = byte(i % 10) @@ -402,11 +398,9 @@ func TestZipEmptyDirectory(t *testing.T) { } defer os.RemoveAll(tmpDir) - // Create empty directory sourceDir := filepath.Join(tmpDir, "empty") os.Mkdir(sourceDir, 0755) - // Create ZIP zipPath := filepath.Join(tmpDir, "empty.zip") config := &models.CompressConfig{ SourcePath: sourceDir, @@ -420,7 +414,6 @@ func TestZipEmptyDirectory(t *testing.T) { t.Fatalf("createZip failed: %v", err) } - // Verify ZIP was created if _, err := os.Stat(zipPath); os.IsNotExist(err) { t.Error("ZIP file was not created") } diff --git a/internal/cli/cli.go b/internal/cli/cli.go index 46e6cc2..3ad0ddd 100644 --- a/internal/cli/cli.go +++ b/internal/cli/cli.go @@ -12,7 +12,6 @@ import ( "zipprine/internal/version" ) -// Run executes the CLI mode func Run() bool { // Define flags compress := flag.String("compress", "", "Compress files/folders (source path)") @@ -32,24 +31,19 @@ func Run() bool { flag.Parse() - // Show version if *showVersion { fmt.Println(version.FullVersion()) return true } - // Show help if *help { printHelp() return true } - - // Check if any CLI flags were provided if flag.NFlag() == 0 { - return false // No flags, use interactive mode + return false } - // Handle remote URL fetching if *remoteURL != "" { if *output == "" { fmt.Println("❌ Error: --output is required when using --url") @@ -68,7 +62,6 @@ func Run() bool { return true } - // Handle compression if *compress != "" { if *output == "" { fmt.Println("❌ Error: --output is required for compression") @@ -105,7 +98,6 @@ func Run() bool { return true } - // Handle extraction if *extract != "" { if *output == "" { fmt.Println("❌ Error: --output is required for extraction") @@ -172,7 +164,6 @@ func Run() bool { return true } - // If we get here, no valid operation was specified fmt.Println("❌ Error: No valid operation specified. Use --help for usage information.") os.Exit(1) return true diff --git a/internal/fetcher/fetcher.go b/internal/fetcher/fetcher.go index 4d608a9..a199b5b 100644 --- a/internal/fetcher/fetcher.go +++ b/internal/fetcher/fetcher.go @@ -15,7 +15,7 @@ import ( // FetchAndExtract downloads an archive from a URL and extracts it to the destination path func FetchAndExtract(archiveURL, destPath string, overwriteAll, preservePerms bool) error { - // Validate URL + parsedURL, err := url.Parse(archiveURL) if err != nil { return fmt.Errorf("invalid URL: %w", err) @@ -25,13 +25,11 @@ func FetchAndExtract(archiveURL, destPath string, overwriteAll, preservePerms bo return fmt.Errorf("only HTTP and HTTPS URLs are supported") } - // Extract filename from URL filename := filepath.Base(parsedURL.Path) if filename == "" || filename == "." || filename == "/" { filename = "archive.tmp" } - // Create temporary directory tempDir, err := os.MkdirTemp("", "zipprine-*") if err != nil { return fmt.Errorf("failed to create temp directory: %w", err) @@ -40,7 +38,6 @@ func FetchAndExtract(archiveURL, destPath string, overwriteAll, preservePerms bo tempFile := filepath.Join(tempDir, filename) - // Download the file fmt.Printf("📥 Downloading from %s...\n", archiveURL) if err := downloadFile(tempFile, archiveURL); err != nil { return fmt.Errorf("failed to download file: %w", err) @@ -48,7 +45,6 @@ func FetchAndExtract(archiveURL, destPath string, overwriteAll, preservePerms bo fmt.Printf("✅ Download complete: %s\n", tempFile) - // Detect archive type archiveType, err := archiver.DetectArchiveType(tempFile) if err != nil { return fmt.Errorf("failed to detect archive type: %w", err) @@ -60,7 +56,6 @@ func FetchAndExtract(archiveURL, destPath string, overwriteAll, preservePerms bo fmt.Printf("📦 Detected archive type: %s\n", archiveType) - // Extract the archive fmt.Printf("📂 Extracting to %s...\n", destPath) extractConfig := &models.ExtractConfig{ ArchivePath: tempFile, @@ -80,14 +75,12 @@ func FetchAndExtract(archiveURL, destPath string, overwriteAll, preservePerms bo // downloadFile downloads a file from a URL to a local path with progress indication func downloadFile(filepath, url string) error { - // Create the file out, err := os.Create(filepath) if err != nil { return err } defer out.Close() - // Get the data resp, err := http.Get(url) if err != nil { return err @@ -99,10 +92,8 @@ func downloadFile(filepath, url string) error { return fmt.Errorf("bad status: %s", resp.Status) } - // Get content length for progress contentLength := resp.ContentLength - // Create progress reader var reader io.Reader = resp.Body if contentLength > 0 { reader = &progressReader{ @@ -119,7 +110,7 @@ func downloadFile(filepath, url string) error { return err } - fmt.Println() // New line after progress + fmt.Println() return nil } diff --git a/internal/ui/autocomplete.go b/internal/ui/autocomplete.go index 8185cee..cf4db90 100644 --- a/internal/ui/autocomplete.go +++ b/internal/ui/autocomplete.go @@ -12,7 +12,6 @@ func getPathCompletions(input string) []string { input = "." } - // Expand home directory if strings.HasPrefix(input, "~") { home, err := os.UserHomeDir() if err == nil { @@ -20,20 +19,16 @@ func getPathCompletions(input string) []string { } } - // Get the directory and file pattern dir := filepath.Dir(input) pattern := filepath.Base(input) - // If input ends with /, we want to list that directory if strings.HasSuffix(input, string(filepath.Separator)) { dir = input pattern = "" } - // Read directory entries, err := os.ReadDir(dir) if err != nil { - // If can't read, try current directory entries, err = os.ReadDir(".") if err != nil { return []string{} @@ -63,7 +58,6 @@ func getPathCompletions(input string) []string { completions = append(completions, fullPath) } - // Limit to 15 suggestions if len(completions) > 15 { completions = completions[:15] } @@ -85,13 +79,11 @@ func getArchiveCompletions(input string) []string { archiveCompletions := []string{} for _, path := range allCompletions { - // Keep directories if strings.HasSuffix(path, string(filepath.Separator)) { archiveCompletions = append(archiveCompletions, path) continue } - // Check if file has archive extension ext := filepath.Ext(path) if archiveExts[ext] { archiveCompletions = append(archiveCompletions, path) diff --git a/internal/ui/batch.go b/internal/ui/batch.go index e23e2d6..90eb69a 100644 --- a/internal/ui/batch.go +++ b/internal/ui/batch.go @@ -228,7 +228,6 @@ func RunBatchExtractFlow() error { fmt.Println(InfoStyle.Render(fmt.Sprintf("📂 Batch extracting %d archives...", len(configs)))) fmt.Println() - // Create batch config batchConfig := &archiver.BatchExtractConfig{ Configs: configs, Parallel: parallel, @@ -246,7 +245,6 @@ func RunBatchExtractFlow() error { errors := archiver.BatchExtract(batchConfig) - // Count successes successCount := 0 for _, err := range errors { if err == nil { diff --git a/internal/ui/compress.go b/internal/ui/compress.go index a4ab9af..2f86179 100644 --- a/internal/ui/compress.go +++ b/internal/ui/compress.go @@ -21,7 +21,6 @@ func RunCompressFlow() error { var verify bool var compressionLevel string - // Get current working directory cwd, _ := os.Getwd() form := huh.NewForm( @@ -124,14 +123,11 @@ func RunCompressFlow() error { } } - // Auto-generate output path if not provided if outputPath == "" { sourceName := filepath.Base(sourcePath) - // Remove trailing slashes sourceName = strings.TrimSuffix(sourceName, string(filepath.Separator)) - // Determine file extension based on archive type var extension string switch models.ArchiveType(archiveTypeStr) { case models.ZIP: @@ -146,7 +142,6 @@ func RunCompressFlow() error { extension = ".zip" } - // Create output path in current working directory outputPath = filepath.Join(cwd, sourceName+extension) fmt.Println(InfoStyle.Render(fmt.Sprintf("📝 Auto-generated output: %s", outputPath))) diff --git a/internal/version/version.go b/internal/version/version.go index 2b79e37..c5c6053 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -8,12 +8,10 @@ const ( Patch = 3 ) -// Version returns the semantic version string func Version() string { return fmt.Sprintf("%d.%d.%d", Major, Minor, Patch) } -// FullVersion returns the version with app name func FullVersion() string { return fmt.Sprintf("Zipprine v%s", Version()) }