mirror of
https://github.com/openai/codex.git
synced 2026-11-05 08:28:29 +00:00
fix: sort codex features list alphabetically (#12944)
## Why `codex features list` currently prints features in declaration order from `codex_core::features::FEATURES`. That makes the output harder to scan when looking for a specific flag, and the order can change for reasons unrelated to the CLI. ## What changed - Sort the `codex features list` rows by feature key before printing them in `codex-rs/cli/src/main.rs`. - Add an integration test in `codex-rs/cli/tests/features.rs` that runs `codex features list` and asserts the feature-name column is alphabetized. ## Verification - Added `features_list_is_sorted_alphabetically_by_feature_name`. - Ran `cargo test -p codex-cli`.
This commit is contained in:
1 parent
951a389654
commit
fd719d3828
2 files changed
+32
No files matched your search
@@ -808,6 +808,7 @@ async fn cli_main(arg0_paths: Arg0DispatchPaths) -> anyhow::Result<()> {
|
|||||||
stage_width = stage_width.max(stage.len());
|
stage_width = stage_width.max(stage.len());
|
||||||
rows.push((name, stage, enabled));
|
rows.push((name, stage, enabled));
|
||||||
}
|
}
|
||||||
|
rows.sort_unstable_by_key(|(name, _, _)| *name);
|
||||||
|
|
||||||
for (name, stage, enabled) in rows {
|
for (name, stage, enabled) in rows {
|
||||||
println!("{name:<name_width$} {stage:<stage_width$} {enabled}");
|
println!("{name:<name_width$} {stage:<stage_width$} {enabled}");
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ use std::path::Path;
|
|||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use predicates::str::contains;
|
use predicates::str::contains;
|
||||||
|
use pretty_assertions::assert_eq;
|
||||||
use tempfile::TempDir;
|
use tempfile::TempDir;
|
||||||
|
|
||||||
fn codex_command(codex_home: &Path) -> Result<assert_cmd::Command> {
|
fn codex_command(codex_home: &Path) -> Result<assert_cmd::Command> {
|
||||||
@@ -58,3 +59,33 @@ async fn features_enable_under_development_feature_prints_warning() -> Result<()
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn features_list_is_sorted_alphabetically_by_feature_name() -> Result<()> {
|
||||||
|
let codex_home = TempDir::new()?;
|
||||||
|
|
||||||
|
let mut cmd = codex_command(codex_home.path())?;
|
||||||
|
let output = cmd
|
||||||
|
.args(["features", "list"])
|
||||||
|
.assert()
|
||||||
|
.success()
|
||||||
|
.get_output()
|
||||||
|
.stdout
|
||||||
|
.clone();
|
||||||
|
let stdout = String::from_utf8(output)?;
|
||||||
|
|
||||||
|
let actual_names = stdout
|
||||||
|
.lines()
|
||||||
|
.map(|line| {
|
||||||
|
line.split_once(" ")
|
||||||
|
.map(|(name, _)| name.trim_end().to_string())
|
||||||
|
.expect("feature list output should contain aligned columns")
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
let mut expected_names = actual_names.clone();
|
||||||
|
expected_names.sort();
|
||||||
|
|
||||||
|
assert_eq!(actual_names, expected_names);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
Reference in new issue
Block a user