Skip to content

Commit 139776d

Browse files
committed
fix: exit with status 1 if property isn't deleted
1 parent ac4b61e commit 139776d

File tree

5 files changed

+27
-15
lines changed

5 files changed

+27
-15
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.14.0
1+
0.14.1

ini.sml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ struct
143143
end
144144

145145
fun stringify (ini: ini_data) : string =
146-
let val sections = map stringifySection ini
147-
val concat = String.concatWith "\n" sections
146+
let
147+
val sections = map stringifySection ini
148+
val concat = String.concatWith "\n" sections
148149
in
149150
if concat = "" then "" else concat ^ "\n"
150151
end

initool.sml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ fun exitWithError (output: string) (err: string) =
3636
OS.Process.exit (OS.Process.failure)
3737
end
3838

39-
datatype result =
40-
Output of string
41-
| FailureOutput of string
42-
| Error of string
39+
datatype result = Output of string | FailureOutput of string | Error of string
4340

4441
fun processFileCustom quiet successFn filterFn filename =
4542
let
@@ -98,7 +95,7 @@ fun helpCommand [] = Output allUsage
9895
Error (invalidUsage ^ (formatArgs (cmd :: rest)) ^ "\n" ^ usage ^ cmd)
9996

10097
fun versionCommand [] =
101-
let val version = "0.14.0"
98+
let val version = "0.14.1"
10299
in Output (version ^ "\n")
103100
end
104101
| versionCommand [_] = versionCommand []
@@ -207,13 +204,11 @@ fun deleteCommand (opts: Id.options) [_, filename, section] =
207204
| deleteCommand opts [_, filename, section, key] =
208205
(* Delete property *)
209206
let
210-
val q =
211-
Ini.RemoveProperty
212-
{ section = Id.fromStringWildcard section
213-
, key = Id.fromStringWildcard key
214-
}
207+
val section = Id.fromStringWildcard section
208+
val key = Id.fromStringWildcard key
209+
val q = Ini.RemoveProperty {section = section, key = key}
215210
val successFn = fn (parsed, _) =>
216-
Ini.sectionExists opts (Id.fromStringWildcard section) parsed
211+
Ini.propertyExists opts section key parsed
217212
in
218213
processFile successFn (Ini.select opts q) filename
219214
end

tests/delete-property.command

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
$INITOOL d tests/test.ini foo name2
1+
$INITOOL d tests/test.ini foo name2 && echo deleted || echo unchanged
2+
$INITOOL d tests/test.ini foo name5 && echo deleted || echo unchanged

tests/delete-property.result

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,18 @@ name2="repeat value"
1010
name1=baz1
1111
name2=baz2
1212
name3=baz3
13+
deleted
14+
[foo]
15+
name1=foo1
16+
name2=foo2
17+
name3="repeat value"
18+
19+
[bar]
20+
name1=bar1
21+
name2="repeat value"
22+
23+
[baz]
24+
name1=baz1
25+
name2=baz2
26+
name3=baz3
27+
unchanged

0 commit comments

Comments
 (0)