Skip to content

Commit

Permalink
Shameless self-promotion
Browse files Browse the repository at this point in the history
ianparkinson committed Nov 25, 2022
1 parent bbf50b4 commit 11a316b
Showing 2 changed files with 38 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/com/github/ianparkinson/helog/Helog.java
Original file line number Diff line number Diff line change
@@ -60,8 +60,18 @@ public void setHost(String host) {
description = "Write the stream exactly as received from the Hubitat Elevation.")
public boolean raw;

@Option(names = "--kofi",
description = "Buy the author a coffee.",
help = true)
public boolean kofi;

@Override
public Integer call() throws URISyntaxException {
if (kofi) {
kofi();
return 0;
}

URI uri = new URI("ws://" + host + "/" + stream.jsonStream.path());
WebSocketSource source = new WebSocketSource(uri);

@@ -77,6 +87,11 @@ private static <T> JsonStreamPrinter<T> createJsonStreamPrinter(JsonStream<T> js
return new JsonStreamPrinter<>(jsonStream.type(), jsonStream.formatter());
}

public static void kofi() {
System.out.println("Thank you!");
System.out.println("https://ko-fi.com/ianparkinson");
}

public static int run(String... args) {
return new CommandLine(new Helog()).setCaseInsensitiveEnumValuesAllowed(true).execute(args);
}
23 changes: 23 additions & 0 deletions src/test/java/com/github/ianparkinson/helog/HelogKofiTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.github.ianparkinson.helog;

import static com.google.common.truth.Truth.assertThat;

import com.github.ianparkinson.helog.testing.StdOutExtension;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

public final class HelogKofiTest {
@RegisterExtension
private final StdOutExtension out = new StdOutExtension();

@Test
public void writesKofiLink() {
Helog.run("--kofi");
assertThat(out.getContent()).contains("ko-fi.com");
}

@Test
public void completesSuccessfully() {
assertThat(Helog.run("--kofi")).isEqualTo(0);
}
}

0 comments on commit 11a316b

Please sign in to comment.