Skip to content

Commit

Permalink
Make things shine
Browse files Browse the repository at this point in the history
  • Loading branch information
ordepdev committed Nov 9, 2019
1 parent 9bf07b0 commit 632f9af
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
12 changes: 9 additions & 3 deletions changelog-tool/changelog.pony
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,15 @@ class Release
fun ref add_entry(section_name: String, entry: String) ? =>
let section =
match section_name
| "fixed" => try fixed as Section else fixed = Section._empty(Fixed); fixed as Section end
| "added" => try added as Section else added = Section._empty(Added); added as Section end
| "changed" => try changed as Section else changed = Section._empty(Changed); changed as Section end
| "fixed" =>
if fixed is None then fixed = Section._empty(Fixed) end
fixed as Section
| "added" =>
if added is None then added = Section._empty(Added) end
added as Section
| "changed" =>
if changed is None then changed = Section._empty(Changed) end
changed as Section
else error
end
section.entries.push("- " + entry)
Expand Down
12 changes: 7 additions & 5 deletions changelog-tool/main.pony
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ actor Main
"Add a new entry at the end of the section",
[edit],
[ ArgSpec.string("section")
ArgSpec.string("entry")
ArgSpec.string("entry")
])?
])?
.> add_help("help", "Print this message and exit")?
Expand Down Expand Up @@ -103,7 +103,9 @@ actor Main
cmd_release(
path, filename, cmd.arg("version").string(), cmd.option("edit").bool())
| "changelog-tool/add" =>
cmd_add(path, filename, cmd.arg("section").string(), cmd.arg("entry").string(), cmd.option("edit").bool())
cmd_add(
path, filename, cmd.arg("section").string(),
cmd.arg("entry").string(),cmd.option("edit").bool())
else
err("unknown command: " + cmd.fullname())
please_report()
Expand Down Expand Up @@ -191,9 +193,9 @@ actor Main
edit_or_print(
filepath,
edit,
Changelog(parse(filepath, filename)?)?
.> add_entry(section, entry)?
.string())
Changelog(parse(filepath, filename)?)?
.> add_entry(section, entry)?
.string())
else
err("unable add a new changelog entry")
end
Expand Down
1 change: 0 additions & 1 deletion tests/main.pony
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ class _ReleaseTestAfterAddingSomeEntries
match r
| let ast: AST =>
_h.log(recover val _Printer(ast) end)
// _h.log(Changelog(ast)?.string())
let changelog = Changelog(ast)?
.> add_entry("fixed", "We made some fixes...\n")?
.> add_entry("fixed", "Oh, and we made a final one.\n")?
Expand Down

0 comments on commit 632f9af

Please sign in to comment.