Skip to content

Commit

Permalink
👔 Return empty string instead of error when section is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
technocidal committed Jul 23, 2024
1 parent 45c2aaa commit df5a255
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
17 changes: 13 additions & 4 deletions Sources/Changelog.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import ArgumentParser
import Foundation
import Markdown
import ArgumentParser
import OSLog

extension Logger {
static let changelog = Logger(subsystem: "swift-changelog-parser", category: "changelog")

}

@main
struct Changelog: ParsableCommand {

static let configuration = CommandConfiguration(
abstract: "Get items from a Changelog.md file for a specific release or that are unreleased.",
version: "1.0.0"
)

enum Release: ExpressibleByArgument, CustomStringConvertible {
case unreleased
case release(String)
Expand All @@ -35,7 +42,7 @@ struct Changelog: ParsableCommand {
}
}
}

@Argument(help: "Path to Changelog.md file")
var path: String

Expand All @@ -61,7 +68,9 @@ struct Changelog: ParsableCommand {

let list = document.child(at: heading.indexInParent + 1)
guard let list, list is UnorderedList else {
throw ValidationError("Changelog does not contain elements in the '\(release.description.localizedCapitalized)' section")
Logger.changelog.info("Changelog does not contain elements in the '\(release.description.localizedCapitalized, privacy: .public)' section")
print("")
return
}

print(list.format().trimmingCharacters(in: .whitespacesAndNewlines))
Expand Down
6 changes: 0 additions & 6 deletions changelog.txt

This file was deleted.

0 comments on commit df5a255

Please sign in to comment.