Skip to content

Commit b7c0459

Browse files
committed
fix: format with rustfmt 1.93 to match CI
1 parent b1648ed commit b7c0459

3 files changed

Lines changed: 49 additions & 42 deletions

File tree

src/backend/qwen.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,16 @@ fn play_wav(path: &Path) -> Result<Child> {
109109
/// Remove orphaned `audio_*.wav` files from the current working directory.
110110
fn cleanup_cwd_wav() {
111111
if let Ok(dir) = std::env::current_dir()
112-
&& let Ok(entries) = std::fs::read_dir(&dir) {
113-
for entry in entries.flatten() {
114-
let name = entry.file_name();
115-
let name_str = name.to_string_lossy();
116-
if name_str.starts_with("audio_") && name_str.ends_with(".wav") {
117-
let _ = std::fs::remove_file(entry.path());
118-
}
112+
&& let Ok(entries) = std::fs::read_dir(&dir)
113+
{
114+
for entry in entries.flatten() {
115+
let name = entry.file_name();
116+
let name_str = name.to_string_lossy();
117+
if name_str.starts_with("audio_") && name_str.ends_with(".wav") {
118+
let _ = std::fs::remove_file(entry.path());
119119
}
120120
}
121+
}
121122
}
122123

123124
impl TtsBackend for QwenBackend {

src/init.rs

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,22 @@ pub fn claude_md_has_vox(content: &str) -> bool {
5050
pub fn has_vox_hook(settings: &Value) -> bool {
5151
if let Some(hooks) = settings.get("hooks")
5252
&& let Some(stop) = hooks.get("Stop")
53-
&& let Some(arr) = stop.as_array() {
54-
for entry in arr {
55-
if let Some(inner_hooks) = entry.get("hooks")
56-
&& let Some(inner_arr) = inner_hooks.as_array() {
57-
for h in inner_arr {
58-
if let Some(cmd) = h.get("command").and_then(|c| c.as_str())
59-
&& cmd.starts_with("vox ") {
60-
return true;
61-
}
62-
}
63-
}
53+
&& let Some(arr) = stop.as_array()
54+
{
55+
for entry in arr {
56+
if let Some(inner_hooks) = entry.get("hooks")
57+
&& let Some(inner_arr) = inner_hooks.as_array()
58+
{
59+
for h in inner_arr {
60+
if let Some(cmd) = h.get("command").and_then(|c| c.as_str())
61+
&& cmd.starts_with("vox ")
62+
{
63+
return true;
64+
}
6465
}
6566
}
67+
}
68+
}
6669
false
6770
}
6871

@@ -97,25 +100,27 @@ pub fn build_settings(existing: Option<&str>) -> Result<String> {
97100

98101
// Merge hooks
99102
if let Some(new_hooks) = vox_hook.get("hooks")
100-
&& let Some(new_stop) = new_hooks.get("Stop") {
101-
let base_obj = base
102-
.as_object_mut()
103-
.context("settings.json is not an object")?;
104-
let hooks_obj = base_obj
105-
.entry("hooks")
106-
.or_insert_with(|| Value::Object(serde_json::Map::new()));
107-
let hooks_map = hooks_obj
108-
.as_object_mut()
109-
.context("hooks is not an object")?;
110-
111-
let stop_arr = hooks_map
112-
.entry("Stop")
113-
.or_insert_with(|| Value::Array(vec![]));
114-
if let Some(arr) = stop_arr.as_array_mut()
115-
&& let Some(new_entries) = new_stop.as_array() {
116-
arr.extend(new_entries.clone());
117-
}
103+
&& let Some(new_stop) = new_hooks.get("Stop")
104+
{
105+
let base_obj = base
106+
.as_object_mut()
107+
.context("settings.json is not an object")?;
108+
let hooks_obj = base_obj
109+
.entry("hooks")
110+
.or_insert_with(|| Value::Object(serde_json::Map::new()));
111+
let hooks_map = hooks_obj
112+
.as_object_mut()
113+
.context("hooks is not an object")?;
114+
115+
let stop_arr = hooks_map
116+
.entry("Stop")
117+
.or_insert_with(|| Value::Array(vec![]));
118+
if let Some(arr) = stop_arr.as_array_mut()
119+
&& let Some(new_entries) = new_stop.as_array()
120+
{
121+
arr.extend(new_entries.clone());
118122
}
123+
}
119124

120125
base
121126
}

src/main.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,13 @@ fn handle_speak(cli: Cli) -> Result<()> {
157157
let mut effective_backend = backend_name.clone();
158158

159159
if let Some(ref voice_name) = voice
160-
&& let Some(vc) = clone::resolve_voice(&conn, voice_name)? {
161-
ref_audio = Some(vc.ref_audio);
162-
ref_text = vc.ref_text;
163-
effective_backend = "qwen".to_string();
164-
voice = None; // don't pass clone name as --voice
165-
}
160+
&& let Some(vc) = clone::resolve_voice(&conn, voice_name)?
161+
{
162+
ref_audio = Some(vc.ref_audio);
163+
ref_text = vc.ref_text;
164+
effective_backend = "qwen".to_string();
165+
voice = None; // don't pass clone name as --voice
166+
}
166167

167168
let backend = backend::get_backend(&effective_backend)?;
168169

0 commit comments

Comments
 (0)