mirror of
https://github.com/openai/codex.git
synced 2026-05-02 18:37:01 +00:00
Remove the legacy TUI split (#15922)
This is the part 1 of 2 PRs that will delete the `tui` / `tui_app_server` split. This part simply deletes the existing `tui` directory and marks the `tui_app_server` feature flag as removed. I left the `tui_app_server` feature flag in place for now so its presence doesn't result in an error. It is simply ignored. Part 2 will rename the `tui_app_server` directory `tui`. I did this as two parts to reduce visible code churn.
This commit is contained in:
@@ -1,70 +0,0 @@
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use codex_shell_command::parse_command::extract_shell_command;
|
||||
use dirs::home_dir;
|
||||
use shlex::try_join;
|
||||
|
||||
pub(crate) fn escape_command(command: &[String]) -> String {
|
||||
try_join(command.iter().map(String::as_str)).unwrap_or_else(|_| command.join(" "))
|
||||
}
|
||||
|
||||
pub(crate) fn strip_bash_lc_and_escape(command: &[String]) -> String {
|
||||
if let Some((_, script)) = extract_shell_command(command) {
|
||||
return script.to_string();
|
||||
}
|
||||
escape_command(command)
|
||||
}
|
||||
|
||||
/// If `path` is absolute and inside $HOME, return the part *after* the home
|
||||
/// directory; otherwise, return the path as-is. Note if `path` is the homedir,
|
||||
/// this will return and empty path.
|
||||
pub(crate) fn relativize_to_home<P>(path: P) -> Option<PathBuf>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
let path = path.as_ref();
|
||||
if !path.is_absolute() {
|
||||
// If the path is not absolute, we can’t do anything with it.
|
||||
return None;
|
||||
}
|
||||
|
||||
let home_dir = home_dir()?;
|
||||
let rel = path.strip_prefix(&home_dir).ok()?;
|
||||
Some(rel.to_path_buf())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_escape_command() {
|
||||
let args = vec!["foo".into(), "bar baz".into(), "weird&stuff".into()];
|
||||
let cmdline = escape_command(&args);
|
||||
assert_eq!(cmdline, "foo 'bar baz' 'weird&stuff'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_strip_bash_lc_and_escape() {
|
||||
// Test bash
|
||||
let args = vec!["bash".into(), "-lc".into(), "echo hello".into()];
|
||||
let cmdline = strip_bash_lc_and_escape(&args);
|
||||
assert_eq!(cmdline, "echo hello");
|
||||
|
||||
// Test zsh
|
||||
let args = vec!["zsh".into(), "-lc".into(), "echo hello".into()];
|
||||
let cmdline = strip_bash_lc_and_escape(&args);
|
||||
assert_eq!(cmdline, "echo hello");
|
||||
|
||||
// Test absolute path to zsh
|
||||
let args = vec!["/usr/bin/zsh".into(), "-lc".into(), "echo hello".into()];
|
||||
let cmdline = strip_bash_lc_and_escape(&args);
|
||||
assert_eq!(cmdline, "echo hello");
|
||||
|
||||
// Test absolute path to bash
|
||||
let args = vec!["/bin/bash".into(), "-lc".into(), "echo hello".into()];
|
||||
let cmdline = strip_bash_lc_and_escape(&args);
|
||||
assert_eq!(cmdline, "echo hello");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user