5 Commits 47f06bd465 ... e475e92ab6

Auteur SHA1 Bericht Datum
  Vadik Sirekanyan e475e92ab6 Updated app version to 1.0.1 2 maanden geleden
  Vadik Sirekanyan 11cfcfaf4c Updated dependencies 2 maanden geleden
  Vadik Sirekanyan 7420e69d01 Implemented priority colors 2 maanden geleden
  Vadik Sirekanyan 0c52a07033 Init 6 maanden geleden
  Vadik Sirekanyan 47f06bd465 Init 6 maanden geleden

+ 32 - 0
.github/workflows/build.yml

@@ -0,0 +1,32 @@
+on:
+  workflow_dispatch:
+  push:
+jobs:
+  build-linux:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions/setup-java@v3
+        with:
+          distribution: 'temurin'
+          java-version: '17'
+      - shell: bash
+        run: ./gradlew linuxX64Binaries -Prelease
+      - shell: bash
+        run: ./gradlew linuxArm64Binaries -Prelease
+      - shell: bash
+        run: ./gradlew linuxX64DistTar linuxArm64DistTar
+  build-macos:
+    runs-on: macos-latest
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions/setup-java@v3
+        with:
+          distribution: 'temurin'
+          java-version: '17'
+      - shell: bash
+        run: ./gradlew macosX64Binaries -Prelease
+      - shell: bash
+        run: ./gradlew macosArm64Binaries -Prelease
+      - shell: bash
+        run: ./gradlew macosX64DistZip macosArm64DistZip

+ 44 - 0
.github/workflows/release.yml

@@ -0,0 +1,44 @@
+on:
+  workflow_dispatch:
+  push:
+    tags:
+      - v*
+jobs:
+  release-linux:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions/setup-java@v3
+        with:
+          distribution: 'temurin'
+          java-version: '17'
+      - shell: bash
+        run: ./gradlew linuxX64Binaries -Prelease
+      - shell: bash
+        run: ./gradlew linuxArm64Binaries -Prelease
+      - shell: bash
+        run: ./gradlew linuxX64DistTar linuxArm64DistTar
+      - if: startsWith(github.ref, 'refs/tags/v')
+        uses: softprops/action-gh-release@v1
+        with:
+          files: |
+            build/distributions/*
+  release-macos:
+    runs-on: macos-latest
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions/setup-java@v3
+        with:
+          distribution: 'temurin'
+          java-version: '17'
+      - shell: bash
+        run: ./gradlew macosX64Binaries -Prelease
+      - shell: bash
+        run: ./gradlew macosArm64Binaries -Prelease
+      - shell: bash
+        run: ./gradlew macosX64DistZip macosArm64DistZip
+      - if: startsWith(github.ref, 'refs/tags/v')
+        uses: softprops/action-gh-release@v1
+        with:
+          files: |
+            build/distributions/*

+ 32 - 17
build.gradle.kts

@@ -1,7 +1,8 @@
 import org.gradle.internal.os.OperatingSystem
+import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
 
 plugins {
-    val kotlinVersion = "2.2.0"
+    val kotlinVersion = "2.2.21"
     kotlin("multiplatform") version kotlinVersion
     kotlin("plugin.serialization") version kotlinVersion
     id("org.sirekanyan.version-checker") version "1.0.14"
@@ -9,7 +10,7 @@ plugins {
 }
 
 group = "org.sirekanyan"
-version = "1.0"
+version = "1.0.1"
 
 repositories {
     mavenCentral()
@@ -18,33 +19,47 @@ repositories {
 dependencies {
     commonMainImplementation("com.github.ajalt.clikt:clikt-core:5.0.3")
     commonMainImplementation("org.jetbrains.kotlinx:kotlinx-datetime:0.7.1")
-    commonMainImplementation("org.jetbrains.kotlinx:kotlinx-io-core:0.8.0")
+    commonMainImplementation("org.jetbrains.kotlinx:kotlinx-io-core:0.8.2")
 }
 
 kotlin {
     val os = OperatingSystem.current()
-    when {
-        os.isLinux -> linuxX64("linux")
-        os.isMacOsX -> macosX64("macos")
-        else -> error("Unsupported operating system: $os")
-    }.binaries {
-        executable(listOf(if (hasProperty("release")) RELEASE else DEBUG))
+    buildList {
+        add(linuxX64())
+        add(linuxArm64())
+        if (os.isMacOsX) {
+            add(macosX64())
+            add(macosArm64())
+        }
+    }.forEach {
+        it.binaries {
+            executable(listOf(if (hasProperty("release")) RELEASE else DEBUG))
+        }
     }
 }
 
+private val kotlinTargetNames: List<String> =
+    kotlin.targets.filterIsInstance<KotlinNativeTarget>().map { it.name }
+
 distributions {
-    main {
-        contents {
-            from("build/bin/linux/releaseExecutable/todo.kexe") {
-                rename { it.removeSuffix(".kexe") }
+    kotlinTargetNames.forEach { targetName ->
+        create(targetName) {
+            distributionBaseName = "todo-${targetName.replace("X64", "-amd64").replace("Arm64", "-arm64")}"
+            contents {
+                from("build/bin/${targetName}/releaseExecutable/todo.kexe") {
+                    rename { it.removeSuffix(".kexe") }
+                }
             }
         }
     }
 }
 
-tasks {
-    getByName<Tar>("distTar") {
-        compression = Compression.GZIP
-        archiveExtension = ".tar.gz"
+kotlinTargetNames.forEach { targetName ->
+    tasks {
+        getByName<Tar>("${targetName}DistTar") {
+            filePermissions { unix("755") }
+            compression = Compression.GZIP
+            archiveExtension = "tar.gz"
+        }
     }
 }

BIN
gradle/wrapper/gradle-wrapper.jar


+ 2 - 2
gradle/wrapper/gradle-wrapper.properties

@@ -1,7 +1,7 @@
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionSha256Sum=8fad3d78296ca518113f3d29016617c7f9367dc005f932bd9d93bf45ba46072b
-distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
+distributionSha256Sum=72f44c9f8ebcb1af43838f45ee5c4aa9c5444898b3468ab3f4af7b6076c5bc3f
+distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
 networkTimeout=10000
 validateDistributionUrl=true
 zipStoreBase=GRADLE_USER_HOME

+ 0 - 3
gradlew

@@ -114,7 +114,6 @@ case "$( uname )" in                #(
   NONSTOP* )        nonstop=true ;;
 esac
 
-CLASSPATH="\\\"\\\""
 
 
 # Determine the Java command to use to start the JVM.
@@ -172,7 +171,6 @@ fi
 # For Cygwin or MSYS, switch paths to Windows format before running java
 if "$cygwin" || "$msys" ; then
     APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
-    CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
 
     JAVACMD=$( cygpath --unix "$JAVACMD" )
 
@@ -212,7 +210,6 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
 
 set -- \
         "-Dorg.gradle.appname=$APP_BASE_NAME" \
-        -classpath "$CLASSPATH" \
         -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
         "$@"
 

+ 1 - 2
gradlew.bat

@@ -70,11 +70,10 @@ goto fail
 :execute
 @rem Setup the command line
 
-set CLASSPATH=
 
 
 @rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
 
 :end
 @rem End local scope for the variables with windows NT shell

+ 8 - 2
install.sh

@@ -12,7 +12,13 @@ esac
 case "$OSTYPE" in
 linux*) OS="linux" ;;
 darwin*) OS="macos" ;;
-*) echo "Unsupported: $OSTYPE" && exit 1 ;;
+*) echo "Unsupported operating system: $OSTYPE" && exit 1 ;;
 esac
 
-sudo ln -sf "$PWD/build/bin/$OS/$MODE/todo.kexe" "/usr/local/bin/todo"
+case "$(arch)" in
+x86_64) ARCH="X64" ;;
+arm64) ARCH="Arm64" ;;
+*) echo "Unsupported architecture: $(arch)" && exit 1 ;;
+esac
+
+sudo ln -sf "$PWD/build/bin/$OS$ARCH/$MODE/todo.kexe" "/usr/local/bin/todo"

+ 17 - 0
snapcraft.yaml

@@ -0,0 +1,17 @@
+name: todo-cli
+base: core24
+version: 1.0.1
+summary: todo command-line app
+description: If you want to get it done, first write it down.
+
+grade: stable
+confinement: strict
+
+parts:
+  todo-cli:
+    plugin: dump
+    source: https://github.com/sirekanian/todo/releases/download/v$SNAPCRAFT_PROJECT_VERSION/todo-linux-$CRAFT_ARCH_BUILD_FOR-$SNAPCRAFT_PROJECT_VERSION.tar.gz
+
+apps:
+  todo-cli:
+    command: todo

+ 7 - 3
src/commonMain/kotlin/org/sirekanyan/todo/ext/List.kt

@@ -4,9 +4,13 @@ fun <T> List<T>.print() {
     forEach(::println)
 }
 
-fun <T> List<T>.printNumbered(start: Int = 1) {
-    val padding = (lastIndex + start).toString().length
-    forEachIndexed { index, entry ->
+fun List<String>.printNumbered() {
+    printNumbered(map(String::colorize), start = 1)
+}
+
+private fun <T> printNumbered(list: List<T>, start: Int) {
+    val padding = (list.lastIndex + start).toString().length
+    list.forEachIndexed { index, entry ->
         println((index + start).toString().padStart(padding) + ' ' + entry)
     }
 }

+ 26 - 0
src/commonMain/kotlin/org/sirekanyan/todo/ext/String.kt

@@ -0,0 +1,26 @@
+package org.sirekanyan.todo.ext
+
+private val priorityRegex = Regex("\\([A-Za-z]\\)")
+
+fun String.colorize(): String {
+    val color = calculateColor(this) ?: return this
+    return "\u001b[${color.code};1m${this}\u001b[0m"
+}
+
+private fun calculateColor(entry: String): Color? {
+    val priority = priorityRegex.findAll(entry)
+        .map(MatchResult::value)
+        .map(String::uppercase)
+        .minOrNull()
+    return when (priority) {
+        null -> null
+        "(A)" -> Color.Red
+        "(B)" -> Color.Yellow
+        "(C)" -> Color.Green
+        else -> Color.Blue
+    }
+}
+
+private enum class Color(val code: Int) {
+    Red(31), Yellow(33), Green(32), Blue(34);
+}