Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ jobs:
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Build Windows binary
env:
RUSTFLAGS: "-C target-feature=+crt-static"
run: |
cargo build --release --target x86_64-pc-windows-msvc

Expand Down Expand Up @@ -79,14 +81,22 @@ jobs:

echo Installing CompressCLI...

REM Check for FFmpeg
where ffmpeg >nul 2>nul
if %errorlevel% neq 0 (
echo Warning: FFmpeg not found. CompressCLI requires FFmpeg for video processing.
echo You can install it via: choco install ffmpeg
echo.
)

REM Check if running as administrator
net session >nul 2>&1
if %errorLevel% == 0 (
set "INSTALL_DIR=%ProgramFiles%\CompressCLI"
set "SYSTEM_INSTALL=1"
set "SCOPE=Machine"
) else (
set "INSTALL_DIR=%USERPROFILE%\.local\bin"
set "SYSTEM_INSTALL=0"
set "SCOPE=User"
)

REM Create installation directory
Expand All @@ -95,25 +105,27 @@ jobs:
REM Copy executable
copy /Y compresscli.exe "%INSTALL_DIR%\"
if %errorlevel% neq 0 (
echo Error: Failed to copy executable
echo Error: Failed to copy executable to %INSTALL_DIR%
pause
exit /b 1
)

echo CompressCLI installed to %INSTALL_DIR%\compresscli.exe

REM Add to PATH if not already there
if %SYSTEM_INSTALL% == 1 (
echo Adding to system PATH...
setx PATH "%PATH%;%INSTALL_DIR%" /M >nul 2>&1
REM Add to PATH safely using PowerShell to avoid 1024-char limit of setx
echo Updating PATH (%SCOPE%)...
powershell -NoProfile -Command "[Environment]::SetEnvironmentVariable('PATH', [Environment]::GetEnvironmentVariable('PATH', '%SCOPE%') + ';%INSTALL_DIR%', '%SCOPE%')"

if %errorlevel% neq 0 (
echo Warning: Failed to update PATH automatically.
echo Please add %INSTALL_DIR% to your PATH manually.
) else (
echo Adding to user PATH...
setx PATH "%PATH%;%INSTALL_DIR%" >nul 2>&1
echo PATH updated successfully.
)

echo.
echo Installation complete!
echo You may need to restart your command prompt for PATH changes to take effect.
echo You MUST restart your command prompt for PATH changes to take effect.
echo.
echo Usage: compresscli --help
pause
Expand Down
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "compresscli"
version = "0.1.2"
edition = "2024"
authors = ["AmitxD"]
categories = ["command-line-utilities", "multimedia"]
description = "A powerful CLI tool for video and image compression"
edition = "2024"
keywords = ["cli", "compression", "ffmpeg", "image", "video"]
license = "MIT"
name = "compresscli"
repository = "https://github.com/amitxd75/compresscli"
keywords = ["compression", "video", "image", "ffmpeg", "cli"]
categories = ["command-line-utilities", "multimedia"]
version = "0.1.3"

[[bin]]
name = "compresscli"
Expand All @@ -17,7 +17,7 @@ path = "src/main.rs"
anyhow = "1.0.99"
bytesize = "2.0.1"
chrono = { version = "0.4.42", features = ["serde"] }
clap = { version = "4.5.47", features = ["derive", "color"] }
clap = { version = "4.5.47", features = ["color", "derive"] }
clap_complete = "4.5.57"
console = "0.16.1"
dirs = "6.0.0"
Expand All @@ -42,7 +42,7 @@ predicates = "3.1.3"
tempfile = "3.22.0"

[profile.release]
lto = true
codegen-units = 1
lto = true
panic = "abort"
strip = true
24 changes: 4 additions & 20 deletions src/utils/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,26 +140,10 @@ pub fn is_image_file<P: AsRef<Path>>(path: P) -> bool {
false
}

/// Safely quotes a path for use in command line arguments
/// Handles paths with spaces and special characters across platforms
/// Converts a path to a string for use in command line arguments.
/// Note: Manual quoting is no longer needed as std::process::Command handles this natively.
pub fn quote_path<P: AsRef<Path>>(path: P) -> String {
let path_str = path.as_ref().to_string_lossy();

// Check if the path contains spaces or special characters that need quoting
if path_str.contains(' ') || path_str.contains('"') || path_str.contains('\\') {
#[cfg(windows)]
{
// On Windows, escape quotes and wrap in quotes
format!("\"{}\"", path_str.replace('"', "\\\""))
}
#[cfg(not(windows))]
{
// On Unix-like systems, escape special characters
format!("'{}'", path_str.replace('\'', "'\\''"))
}
} else {
path_str.to_string()
}
path.as_ref().to_string_lossy().to_string()
}

/// Validates that a path is safe for use in commands
Expand Down Expand Up @@ -218,7 +202,7 @@ mod tests {
// Test path with spaces
let path_with_spaces = "/path with spaces/file.txt";
let quoted = quote_path(path_with_spaces);
assert!(quoted.starts_with('\'') || quoted.starts_with('"'));
assert_eq!(quoted, path_with_spaces);
}

#[test]
Expand Down
Loading