mirror of
				https://github.com/edera-dev/krata.git
				synced 2025-11-03 23:29:39 +00:00 
			
		
		
		
	@ -21,6 +21,8 @@ pub struct ZoneExecCommand {
 | 
			
		||||
    env: Option<Vec<String>>,
 | 
			
		||||
    #[arg(short = 'w', long, help = "Working directory")]
 | 
			
		||||
    working_directory: Option<String>,
 | 
			
		||||
    #[arg(short = 't', long, help = "Allocate tty")]
 | 
			
		||||
    tty: bool,
 | 
			
		||||
    #[arg(help = "Zone to exec inside, either the name or the uuid")]
 | 
			
		||||
    zone: String,
 | 
			
		||||
    #[arg(
 | 
			
		||||
@ -46,8 +48,10 @@ impl ZoneExecCommand {
 | 
			
		||||
                    .collect(),
 | 
			
		||||
                command: self.command,
 | 
			
		||||
                working_directory: self.working_directory.unwrap_or_default(),
 | 
			
		||||
                tty: self.tty,
 | 
			
		||||
            }),
 | 
			
		||||
            data: vec![],
 | 
			
		||||
            stdin: vec![],
 | 
			
		||||
            stdin_closed: false,
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        let stream = StdioConsoleStream::stdin_stream_exec(initial).await;
 | 
			
		||||
@ -57,7 +61,7 @@ impl ZoneExecCommand {
 | 
			
		||||
            .await?
 | 
			
		||||
            .into_inner();
 | 
			
		||||
 | 
			
		||||
        let code = StdioConsoleStream::exec_output(response).await?;
 | 
			
		||||
        let code = StdioConsoleStream::exec_output(response, self.tty).await?;
 | 
			
		||||
        std::process::exit(code);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -59,6 +59,8 @@ pub struct ZoneLaunchCommand {
 | 
			
		||||
    device: Vec<String>,
 | 
			
		||||
    #[arg[short, long, help = "Environment variables set in the zone"]]
 | 
			
		||||
    env: Option<Vec<String>>,
 | 
			
		||||
    #[arg(short = 't', long, help = "Allocate tty for task")]
 | 
			
		||||
    tty: bool,
 | 
			
		||||
    #[arg(
 | 
			
		||||
        short,
 | 
			
		||||
        long,
 | 
			
		||||
@ -143,6 +145,7 @@ impl ZoneLaunchCommand {
 | 
			
		||||
                        .collect(),
 | 
			
		||||
                    command: self.command,
 | 
			
		||||
                    working_directory: self.working_directory.unwrap_or_default(),
 | 
			
		||||
                    tty: self.tty,
 | 
			
		||||
                }),
 | 
			
		||||
                annotations: vec![],
 | 
			
		||||
                devices: self
 | 
			
		||||
 | 
			
		||||
@ -112,7 +112,7 @@ impl ZoneTopApp {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn render_frame(&mut self, frame: &mut Frame) {
 | 
			
		||||
        frame.render_widget(self, frame.size());
 | 
			
		||||
        frame.render_widget(self, frame.area());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn handle_event(&mut self, event: Event) -> io::Result<()> {
 | 
			
		||||
 | 
			
		||||
@ -62,11 +62,15 @@ impl StdioConsoleStream {
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                };
 | 
			
		||||
                let data = buffer[0..size].to_vec();
 | 
			
		||||
                let stdin = buffer[0..size].to_vec();
 | 
			
		||||
                if size == 1 && buffer[0] == 0x1d {
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
                yield ExecInsideZoneRequest { zone_id: String::default(), task: None, data };
 | 
			
		||||
                let stdin_closed = size == 0;
 | 
			
		||||
                yield ExecInsideZoneRequest { zone_id: String::default(), task: None, stdin, stdin_closed, };
 | 
			
		||||
                if stdin_closed {
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@ -88,7 +92,11 @@ impl StdioConsoleStream {
 | 
			
		||||
        Ok(())
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub async fn exec_output(mut stream: Streaming<ExecInsideZoneReply>) -> Result<i32> {
 | 
			
		||||
    pub async fn exec_output(mut stream: Streaming<ExecInsideZoneReply>, raw: bool) -> Result<i32> {
 | 
			
		||||
        if raw && stdin().is_tty() {
 | 
			
		||||
            enable_raw_mode()?;
 | 
			
		||||
            StdioConsoleStream::register_terminal_restore_hook()?;
 | 
			
		||||
        }
 | 
			
		||||
        let mut stdout = stdout();
 | 
			
		||||
        let mut stderr = stderr();
 | 
			
		||||
        while let Some(reply) = stream.next().await {
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user