mirror of
https://codeberg.org/icewind/haze.git
synced 2026-06-03 17:14:08 +02:00
edit command
This commit is contained in:
parent
7a96e6cd71
commit
43481a5960
5 changed files with 70 additions and 9 deletions
13
src/main.rs
13
src/main.rs
|
|
@ -16,7 +16,7 @@ use crate::service::{RedisTls, Service};
|
|||
use bollard::Docker;
|
||||
use itertools::Itertools;
|
||||
use miette::{IntoDiagnostic, Report, Result, WrapErr};
|
||||
use std::env::vars;
|
||||
use std::env::{var, vars};
|
||||
use std::fs::{create_dir_all, write};
|
||||
use std::io::stdout;
|
||||
use std::os::unix::process::CommandExt;
|
||||
|
|
@ -452,6 +452,17 @@ async fn main() -> Result<ExitCode> {
|
|||
HazeArgs::Help { command } => {
|
||||
help(command);
|
||||
}
|
||||
HazeArgs::Edit { filter, path } => {
|
||||
let cloud = Cloud::get_by_filter(&docker, filter, &config).await?;
|
||||
let path = cloud
|
||||
.get_local_path(&config, &path)
|
||||
.ok_or_else(|| Report::msg(format!("{path} not found on the instance")))?;
|
||||
let editor = var("EDITOR").map_err(|_| Report::msg("$EDITOR not set"))?;
|
||||
let err = Command::new(editor).arg(path).exec(); // this never exists without error
|
||||
return Err(err)
|
||||
.into_diagnostic()
|
||||
.wrap_err("Failed to start $EDITOR");
|
||||
}
|
||||
};
|
||||
|
||||
Ok(ExitCode::SUCCESS)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue