use assert_cmd::Command;
use predicates::prelude::*;

#[test]
fn help_mentions_core_commands() {
    let mut cmd = Command::cargo_bin("dictx").unwrap();
    cmd.arg("--help")
        .assert()
        .success()
        .stdout(predicate::str::contains("lookup"))
        .stdout(predicate::str::contains("build"))
        .stdout(predicate::str::contains("ai"));
}

#[test]
fn config_set_get_roundtrip() {
    let temp = tempfile::tempdir().unwrap();
    let config = temp.path().join("config.toml");

    Command::cargo_bin("dictx")
        .unwrap()
        .args([
            "--config",
            config.to_str().unwrap(),
            "config",
            "set",
            "search.default_limit",
            "7",
        ])
        .assert()
        .success();

    Command::cargo_bin("dictx")
        .unwrap()
        .args([
            "--config",
            config.to_str().unwrap(),
            "config",
            "get",
            "search.default_limit",
        ])
        .assert()
        .success()
        .stdout(predicate::str::contains("7"));
}
