8000 Require Inko 0.18.0 or newer · yorickpeterse/clogs@4c36590 · GitHub
[go: up one dir, main page]

Skip to content

Commit

Permalink
Require Inko 0.18.0 or newer
Browse files Browse the repository at this point in the history
Changelog: changed
  • Loading branch information
yorickpeterse committed Feb 11, 2025
1 parent 85ed5d6 commit 4c36590
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 43 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ changelog.

## Requirements

- Inko 0.17.0 or newer
- Inko 0.18.0 or newer
- Git

Generating changelogs comes with the following workflow requirements:
Expand Down
2 changes: 1 addition & 1 deletion inko.pkg
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require inko 0.17.0
require inko 0.18.0
6 changes: 3 additions & 3 deletions src/clogs/changelog.inko
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn format_date(date: ref DateTime) -> String {
'${date.year}-${date.month.to_string.pad_start('0', chars: 2)}-${date.day.to_string.pad_start('0', chars: 2)}'
}

class Release {
type Release {
let @config: ref Config
let @version: Version
let @previous_version: Option[Version]
Expand Down Expand Up @@ -75,9 +75,9 @@ impl ToString for Release {
}
}

class Changelog {
type Changelog {
let @path: Path
let @data: String
let mut @data: String

fn static load(path: ref Path) -> Result[Changelog, Error] {
let data = if path.file? {
Expand Down
6 changes: 3 additions & 3 deletions src/clogs/cli.inko
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import std.time (DateTime)

let VERSION = '0.7.0'

fn show_help(options: ref Options, output: mut Write) {
fn show_help[T: mut + Write](options: ref Options, output: mut T) {
let help = Help
.new('clogs')
.usage('[OPTIONS] [VERSION | COMMAND]')
Expand All @@ -26,10 +26,10 @@ fn show_help(options: ref Options, output: mut Write) {
output.write_string(help).get
}

fn pub run(
fn pub run[T: mut + Write](
arguments: Array[String],
working_directory: ref Path,
output: mut Write,
output: T,
) -> Result[Nil, String] {
let opts = Options.new

Expand Down
17 changes: 7 additions & 10 deletions src/clogs/config.inko
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let DEFAULT_CATEGORIES = [
['other', 'Other'],
]

class enum Error {
type inline enum Error {
# The configuration file couldn't be loaded (e.g. it doesn't exist).
case InvalidFile(IoError)

Expand Down Expand Up @@ -59,8 +59,8 @@ impl ToString for Error {
}
}

class Config {
let @url: String
type Config {
let mut @url: String
let @changelog: Path
let @categories: Map[String, String]

Expand All @@ -76,14 +76,11 @@ class Config {
}

fn static load(path: ref Path) -> Result[Config, Error] {
let buf = ByteArray.new

try ReadOnlyFile
.new(path.clone)
.then(fn (file) { file.read_all(buf) })
.map_error(fn (e) { Error.InvalidFile(e) })
let file = try ReadOnlyFile.new(path.clone).map_error(fn (e) {
Error.InvalidFile(e)
})

let doc = match Json.parse(buf) {
let doc = match Json.parse(file) {
case Ok(Object(map)) -> map
case Ok(_) -> throw Error.InvalidRoot
case Error(e) -> throw Error.InvalidSyntax(e.to_string)
Expand Down
8 changes: 4 additions & 4 deletions src/clogs/git.inko
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let REVERT_TEXT = 'This reverts commit '
let SHA_SIZE = 40

# An error produced when running Git commands.
class enum Error {
type inline enum Error {
# The Git command failed to run, such as due to it not existing, or a lack of
# permissions.
case Invalid(IoError)
Expand All @@ -47,7 +47,7 @@ impl ToString for Error {
# An iterator over the lines of a process' STDOUT stream.
#
# The produced lines _don't_ include the trailing newline.
class Output {
type inline Output {
let @child: sys.ChildProcess
let @stdout: BufferedReader[sys.Stdout]
let @buffer: ByteArray
Expand Down Expand Up @@ -76,7 +76,7 @@ impl Iter[String] for Output {
}
}

class Commit {
type Commit {
let @id: String
let @subject: String
let @category: String
Expand All @@ -91,7 +91,7 @@ class Commit {
}
}

class Repository {
type inline Repository {
let @path: Path

fn static new(path: ref Path) -> Repository {
Expand Down
8 changes: 4 additions & 4 deletions src/clogs/version.inko
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import std.string (ToString)

# A type that represents a version number, per semantic versioning
# (https://semver.org/).
class Version {
type copy Version {
let @major: Int
let @minor: Int
let @patch: Int
Expand Down Expand Up @@ -58,13 +58,13 @@ impl ToString for Version {
}
}

impl Equal[ref Version] for Version {
impl Equal for Version {
fn pub ==(other: ref Version) -> Bool {
@major == other.major and @minor == other.minor and @patch == other.patch
}
}

impl Compare[Version] for Version {
impl Compare for Version {
fn pub cmp(other: ref Version) -> Ordering {
match @major.cmp(other.major) {
case Equal -> {
Expand All @@ -84,7 +84,7 @@ impl FormatTrait for Version {
}
}

impl Clone[Version] for Version {
impl Clone for Version {
fn pub clone -> Version {
Version(major: @major, minor: @minor, patch: @patch)
}
Expand Down
5 changes: 2 additions & 3 deletions src/main.inko
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import clogs.cli
import std.env (arguments, working_directory)
import std.io (Write)
import std.stdio (Stderr, Stdout)
import std.sys (exit)

class async Main {
type async Main {
fn async main {
# This is needed to work around
# https://github.com/inko-lang/inko/issues/631.
let out = Stdout.new as Write
let out = Stdout.new
let pwd = working_directory.or_else(fn (_) { '.'.to_path })

match cli.run(arguments, pwd, out) {
Expand Down
13 changes: 4 additions & 9 deletions test/clogs/test_changelog.inko
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import clogs.git (Commit)
import clogs.helpers (with_file_path, write)
import clogs.version (Version)
import std.test (Tests)
import std.time (DateTime)
import std.time (Date, DateTime, Time)

fn config -> Config {
let conf = Config.default
Expand All @@ -18,14 +18,9 @@ fn release(config: ref Config) -> Release {
config,
version: Version.new(1, 0, 1),
previous_version: Option.Some(Version.new(1, 0, 0)),
date: DateTime(
year: 2023,
month: 8,
day: 5,
hour: 12,
minute: 15,
second: 30,
sub_second: 0.0,
date: DateTime.new(
date: Date.new(year: 2023, month: 8, day: 5).get,
time: Time.new(hour: 12, minute: 15, second: 30, nanosecond: 0).get,
utc_offset: 0,
),
)
Expand Down
10 changes: 5 additions & 5 deletions test/clogs/test_cli.inko
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ import clogs.cli
import clogs.config (CONFIG_FILE, Config)
import clogs.git (Repository)
import clogs.helpers (read, with_directory, with_repository)
import std.io (Write)
import std.io (Error, Write)
import std.optparse (Options)
import std.test (Tests)

class Writer {
type Writer {
let @buffer: mut ByteArray
}

impl Write for Writer {
fn pub mut write_string(string: String) -> Result[Nil, Never] {
fn pub mut write_string(string: String) -> Result[Nil, Error] {
@buffer.append(string.to_byte_array)
Result.Ok(nil)
}

fn pub mut write_bytes(bytes: ref ByteArray) -> Result[Nil, Never] {
fn pub mut write_bytes(bytes: ref ByteArray) -> Result[Nil, Error] {
@buffer.copy_from(bytes, at: 0, size: bytes.size)
Result.Ok(nil)
}

fn pub mut flush -> Result[Nil, Never] {
fn pub mut flush -> Result[Nil, Error] {
Result.Ok(nil)
}
}
Expand Down

0 comments on commit 4c36590

Please sign in to comment.
0