Display working dir (#7419)
Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
@@ -2,15 +2,27 @@ use crate::session::message_to_markdown;
|
|||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
|
|
||||||
use cliclack::{confirm, multiselect, select};
|
use cliclack::{confirm, multiselect, select};
|
||||||
|
use etcetera::home_dir;
|
||||||
use goose::session::{generate_diagnostics, Session, SessionManager};
|
use goose::session::{generate_diagnostics, Session, SessionManager};
|
||||||
use goose::utils::safe_truncate;
|
use goose::utils::safe_truncate;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
use std::path::Path;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
const TRUNCATED_DESC_LENGTH: usize = 60;
|
const TRUNCATED_DESC_LENGTH: usize = 60;
|
||||||
|
|
||||||
|
fn display_path_with_tilde(path: &Path) -> String {
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
if let Ok(home) = home_dir() {
|
||||||
|
if let Ok(stripped) = path.strip_prefix(&home) {
|
||||||
|
return format!("~/{}", stripped.display());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
path.display().to_string()
|
||||||
|
}
|
||||||
|
|
||||||
async fn remove_sessions(session_manager: &SessionManager, sessions: Vec<Session>) -> Result<()> {
|
async fn remove_sessions(session_manager: &SessionManager, sessions: Vec<Session>) -> Result<()> {
|
||||||
println!("The following sessions will be removed:");
|
println!("The following sessions will be removed:");
|
||||||
for session in &sessions {
|
for session in &sessions {
|
||||||
@@ -170,7 +182,13 @@ pub async fn handle_session_list(
|
|||||||
|
|
||||||
println!("Available sessions:");
|
println!("Available sessions:");
|
||||||
for session in sessions {
|
for session in sessions {
|
||||||
let output = format!("{} - {} - {}", session.id, session.name, session.updated_at);
|
let output = format!(
|
||||||
|
"{} - {} - {} - {}",
|
||||||
|
session.id,
|
||||||
|
session.name,
|
||||||
|
session.updated_at,
|
||||||
|
display_path_with_tilde(&session.working_dir)
|
||||||
|
);
|
||||||
println!("{}", output);
|
println!("{}", output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user