Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changepacks/changepack_log_0Kb8pyLk1JRzOnqeBEXpJ.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"changes":{"crates/vespertide-config/Cargo.toml":"Patch","crates/vespertide-loader/Cargo.toml":"Patch","crates/vespertide-planner/Cargo.toml":"Patch","crates/vespertide-naming/Cargo.toml":"Patch","crates/vespertide-macro/Cargo.toml":"Patch","crates/vespertide/Cargo.toml":"Patch","crates/vespertide-cli/Cargo.toml":"Patch","crates/vespertide-exporter/Cargo.toml":"Patch","crates/vespertide-core/Cargo.toml":"Patch","crates/vespertide-query/Cargo.toml":"Patch"},"note":"Allow empty value","date":"2026-01-14T08:27:19.993592200Z"}
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 48 additions & 2 deletions crates/vespertide-cli/src/commands/revision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,32 @@ fn print_fill_with_item_and_get_prompt(
format_fill_with_prompt(table, column)
}

/// Wrap a value with single quotes if it contains spaces and isn't already quoted.
fn wrap_if_spaces(value: String) -> String {
if value.is_empty() {
return value;
}
// Already wrapped with single quotes
if value.starts_with('\'') && value.ends_with('\'') {
return value;
}
// Contains spaces: wrap with single quotes
if value.contains(' ') {
return format!("'{}'", value);
}
value
}

/// Prompt the user for a fill_with value using dialoguer.
/// This function wraps terminal I/O and cannot be unit tested without a real terminal.
#[cfg(not(tarpaulin_include))]
fn prompt_fill_with_value(prompt: &str) -> Result<String> {
Input::new()
let value = Input::new()
.with_prompt(prompt)
.allow_empty(true)
.interact_text()
.context("failed to read input")
.context("failed to read input")?;
Ok(wrap_if_spaces(value))
}

/// Collect fill_with values interactively for missing columns.
Expand Down Expand Up @@ -1097,4 +1115,32 @@ mod tests {
_ => panic!("Expected ModifyColumnNullable action"),
}
}

#[test]
fn test_wrap_if_spaces_empty() {
assert_eq!(wrap_if_spaces("".to_string()), "");
}

#[test]
fn test_wrap_if_spaces_no_spaces() {
assert_eq!(wrap_if_spaces("value".to_string()), "value");
}

#[test]
fn test_wrap_if_spaces_with_spaces() {
assert_eq!(wrap_if_spaces("my value".to_string()), "'my value'");
}

#[test]
fn test_wrap_if_spaces_already_quoted() {
assert_eq!(
wrap_if_spaces("'already quoted'".to_string()),
"'already quoted'"
);
}

#[test]
fn test_wrap_if_spaces_multiple_spaces() {
assert_eq!(wrap_if_spaces("a b c".to_string()), "'a b c'");
}
}