bae6f36f4351

read an empty --name= as an empty value instead of taking the next word (3.2.21)

time
2026-09-29 13:27 UTC · 2 weeks ago
machine
Junes-MacBook-Pro.local
agent
claude-sonnet-5-5
session
comment and tidy pass
parent
064fb290d6cf
4 files VERSION+1 −1src/cli/args.v+4 −2src/cli/args_test.v+16 −0v.mod+1 −1
VERSION+1 −1
@@ -1 +1 @@1-3.2.201+3.2.21

view file

src/cli/args.v+4 −2
@@ -35,13 +35,15 @@3535 		if item.starts_with('--') {3636 			mut name := item[2..]3737 			mut inline := ''38+			mut has_inline := false3839 			if at := name.index('=') {3940 				inline = name[at + 1..]4041 				name = name[..at]42+				has_inline = true4143 			}4244 			if name in spec.values {4345 				mut value := inline44-				if value == '' {46+				if !has_inline {4547 					index++4648 					if index >= raw.len {4749 						return error('--${name} needs a value')@@ -51,7 +53,7 @@5153 				args.values[name] = value5254 				args.multi[name] << value5355 			} else if name in spec.flags {54-				if inline != '' {56+				if has_inline {5557 					return error('--${name} takes no value')5658 				}5759 				args.flags[name] = true

view file

src/cli/args_test.v+16 −0
@@ -0,0 +1,16 @@1+module cli2+3+fn test_an_empty_inline_value_is_a_value_and_takes_no_more_words() {4+	args := parse('offer', ['--notes=', 'extra'], Options{5+		values: ['notes']6+	})!7+	assert args.value_or_none('notes') or { 'missing' } == ''8+	assert args.positional == ['extra']9+}10+11+fn test_an_empty_next_word_is_still_a_value() {12+	args := parse('offer', ['--notes', ''], Options{13+		values: ['notes']14+	})!15+	assert args.value_or_none('notes') or { 'missing' } == ''16+}

view file

v.mod+1 −1
@@ -1,6 +1,6 @@11 Module {22 	name: 'koh3'3-	version: '3.2.20'3+	version: '3.2.21'44 	description: 'One SQLite file per repo, one line of history.'55 	license: 'MIT'66 }

view file