omni/commands/
push.rs

1use crate::ui::PremiumUI;
2use anyhow::Result;
3use console::style;
4use dialoguer::{Input, Select};
5use std::{thread, time::Duration};
6
7impl PremiumUI {
8    pub async fn push_interactive(&self) -> Result<()> {
9        let tag: String = Input::with_theme(&self.theme)
10            .with_prompt("Enter image tag")
11            .default("latest".into())
12            .interact_text()?;
13
14        let registries = vec!["Docker Hub", "Google Container Registry", "Amazon ECR"];
15        let registry = Select::with_theme(&self.theme)
16            .with_prompt("Select registry")
17            .items(&registries)
18            .interact()?;
19
20        println!("\n{}", style("📦 Pushing image...").cyan().bold());
21
22        let pb = self.create_progress_bar(100, "Preparing image");
23        for i in 0..100 {
24            pb.inc(1);
25            thread::sleep(Duration::from_millis(50));
26
27            match i {
28                20 => pb.set_message("Building layers..."),
29                50 => pb.set_message("Optimizing image..."),
30                80 => pb.set_message("Pushing to registry..."),
31                _ => {}
32            }
33        }
34        pb.finish_with_message("✓ Image pushed successfully!");
35
36        println!("\n{}", style("🏷️  Image Details").cyan().bold());
37        println!("Registry: {}", style(registries[registry]).green());
38        println!("Tag:      {}", style(tag).green());
39        println!("Size:     {}", style("156.4 MB").green());
40        println!("Layers:   {}", style("12").green());
41
42        Ok(())
43    }
44}