Skip to content

Commit

Permalink
refactor: change config field name (#1042)
Browse files Browse the repository at this point in the history
append_command_to_history_file => save_shell_history
  • Loading branch information
sigoden authored Dec 6, 2024
1 parent b164a15 commit af4ff7a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ right_prompt:
# ---- misc ----
serve_addr: 127.0.0.1:8000 # Default serve listening address
user_agent: null # Set User-Agent HTTP header, use `auto` for aichat/<current-version>
append_command_to_history_file: true # Weather to append shell execute command to the history file
save_shell_history: true # Whether to save shell execution command to the history file

# ---- clients ----
clients:
Expand Down
8 changes: 4 additions & 4 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ pub struct Config {

pub serve_addr: Option<String>,
pub user_agent: Option<String>,
pub append_command_to_history_file: bool,
pub save_shell_history: bool,

pub clients: Vec<ClientConfig>,

Expand Down Expand Up @@ -210,7 +210,7 @@ impl Default for Config {

serve_addr: None,
user_agent: None,
append_command_to_history_file: true,
save_shell_history: true,

clients: vec![],

Expand Down Expand Up @@ -2258,8 +2258,8 @@ impl Config {
if let Some(v) = read_env_value::<String>(&get_env_name("user_agent")) {
self.user_agent = v;
}
if let Some(Some(v)) = read_env_bool(&get_env_name("append_command_to_history_file")) {
self.append_command_to_history_file = v;
if let Some(Some(v)) = read_env_bool(&get_env_name("save_shell_history")) {
self.save_shell_history = v;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ async fn shell_execute(
"e" => {
debug!("{} {:?}", shell.cmd, &[&shell.arg, &eval_str]);
let code = run_command(&shell.cmd, &[&shell.arg, &eval_str], None)?;
if code == 0 && config.read().append_command_to_history_file {
if code == 0 && config.read().save_shell_history {
let _ = append_to_shell_history(&shell.name, &eval_str, code);
}
process::exit(code);
Expand Down

0 comments on commit af4ff7a

Please sign in to comment.