Skip to content

Terminal interface to find, download, and stream movies, TV shows, and live TV using local media players.

feat: add version flag to CLI and force updates during installation scripts

Samir Hossains8a16e9f74208
diff --git a/install.ps1 b/install.ps1
index d81edbe..058c2d5 100644
--- a/install.ps1
+++ b/install.ps1
@@ -21,27 +21,15 @@ try {
$IsUpdate = $false
if (Test-Path $ExePath) {
- try {
- $CurrentVersionOutput = & $ExePath --version 2>&1
- $CurrentVersion = ($CurrentVersionOutput -split ' ')[1]
-
- if ("v$CurrentVersion" -eq $Version) {
- Write-Success "You already have the latest version ($Version) installed."
- exit 0
- }
- Write-Info "Updating MovieBox-TUI from v$CurrentVersion to $Version..."
- $IsUpdate = $true
-
- # Ensure it's not running
- $RunningProcesses = Get-Process -Name "moviebox-tui" -ErrorAction SilentlyContinue
- if ($RunningProcesses) {
- Write-Info "Stopping running instances of MovieBox-Tui..."
- $RunningProcesses | Stop-Process -Force
- Start-Sleep -Seconds 1
- }
- } catch {
- Write-Info "Updating MovieBox-TUI to $Version..."
- $IsUpdate = $true
+ Write-Info "MovieBox-TUI is already installed. Forcing update to $Version..."
+ $IsUpdate = $true
+
+ # Ensure it's not running
+ $RunningProcesses = Get-Process -Name "moviebox-tui" -ErrorAction SilentlyContinue
+ if ($RunningProcesses) {
+ Write-Info "Stopping running instances of MovieBox-Tui..."
+ $RunningProcesses | Stop-Process -Force
+ Start-Sleep -Seconds 1
}
} else {
Write-Info "Installing MovieBox-TUI $Version..."
diff --git a/install.sh b/install.sh
index fb78d3c..9ba882e 100644
--- a/install.sh
+++ b/install.sh
@@ -22,12 +22,7 @@ VERSION=$(echo "$LATEST_RELEASE" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/
[ -z "$VERSION" ] && log_err "Failed to fetch latest version from GitHub API."
if command -v "$BIN_NAME" > /dev/null 2>&1; then
- CURRENT_VERSION=$($BIN_NAME --version 2>/dev/null | awk '{print $2}' || echo "unknown")
- if [ "v$CURRENT_VERSION" = "$VERSION" ]; then
- log_success "You already have the latest version ($VERSION) installed."
- exit 0
- fi
- log_info "Updating MovieBox-TUI from v$CURRENT_VERSION to $VERSION..."
+ log_info "MovieBox-TUI is already installed. Forcing update to $VERSION..."
IS_UPDATE=1
else
log_info "Installing MovieBox-TUI $VERSION..."
diff --git a/src/main.rs b/src/main.rs
index f4ce0b7..43c4bff 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -15,6 +15,12 @@ impl Drop for TerminalGuard {
#[tokio::main]
async fn main() -> std::io::Result<()> {
+ let args: Vec<String> = std::env::args().collect();
+ if args.iter().any(|arg| arg == "--version" || arg == "-v" || arg == "-V") {
+ println!("moviebox-tui {}", env!("CARGO_PKG_VERSION"));
+ return Ok(());
+ }
+
let stdout = std::io::stdout();
let backend =
ratatui::backend::CrosstermBackend::new(std::io::BufWriter::with_capacity(65536, stdout));