{"id":18784516,"url":"https://github.com/pwittchen/kirai","last_synced_at":"2025-04-13T12:33:09.059Z","repository":{"id":25628944,"uuid":"29064226","full_name":"pwittchen/kirai","owner":"pwittchen","description":"String formatting library for Java, Android, Web and Unix Terminal","archived":false,"fork":false,"pushed_at":"2020-01-15T11:13:05.000Z","size":387,"stargazers_count":73,"open_issues_count":0,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-27T03:35:18.844Z","etag":null,"topics":["android","formatter","formatting","java","string","terminal","unix"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pwittchen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["pwittchen"],"custom":["https://paypal.me/pwittchen"]}},"created_at":"2015-01-10T17:07:43.000Z","updated_at":"2025-01-11T06:39:13.000Z","dependencies_parsed_at":"2022-09-09T19:10:52.000Z","dependency_job_id":null,"html_url":"https://github.com/pwittchen/kirai","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwittchen%2Fkirai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwittchen%2Fkirai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwittchen%2Fkirai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pwittchen%2Fkirai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pwittchen","download_url":"https://codeload.github.com/pwittchen/kirai/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248714730,"owners_count":21149956,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","formatter","formatting","java","string","terminal","unix"],"created_at":"2024-11-07T20:43:16.192Z","updated_at":"2025-04-13T12:33:08.688Z","avatar_url":"https://github.com/pwittchen.png","language":"Java","funding_links":["https://github.com/sponsors/pwittchen","https://paypal.me/pwittchen"],"categories":[],"sub_categories":[],"readme":"Kirai\n=====\n\n[![Build Status](https://travis-ci.org/pwittchen/kirai.svg?branch=master)](https://travis-ci.org/pwittchen/kirai)  [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Kirai-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1391) ![Maven Central](https://img.shields.io/maven-central/v/com.github.pwittchen.kirai/library.svg?style=flat) [![codecov](https://codecov.io/gh/pwittchen/kirai/branch/master/graph/badge.svg)](https://codecov.io/gh/pwittchen/kirai)\n\nKirai means *phrase* in Swahili language. It's string formatting library for Java, Android, Web and Unix Terminal.\n\nProject is inspired by [phrase](https://github.com/square/phrase), [TaggerString](https://github.com/polok/TaggerString) and [BabushkaText](https://github.com/quiqueqs/BabushkaText).\nKirai has fluent API similar to phrase with additional formatting similar to TaggerString and allows to add formatted pieces of text like BabushkaText.\n\nJavaDoc is available at: http://pwittchen.github.io/kirai/\n\nLibrary is compatible with Java 1.7 and higher. It should work with Java 1.6 and is compatible with Android applications.\n\nContents\n--------\n- [Usage](#usage)\n  - [Basic](#basic)\n  - [Android](#android)\n  - [Web](#web)\n  - [Terminal](#terminal)\n- [Download](#download)\n- [Building project](#building-project)\n- [Tests](#tests)\n- [Static Code Analysis](#static-code-analysis)\n- [Code style](#code-style)\n- [License](#license)\n\nUsage\n-----\n\n### Basic\n\n```java\nCharSequence formatted = Kirai\n  .from(\"Hi {first_name}, your are {age} years old.\")\n  .put(\"first_name\", firstName)\n  .put(\"age\", age)\n  .format();\n```\n\n### Android\n\n```java\nCharSequence formatted = Kirai\n  .from(\"Hi {first_name}, your are {age} years old.\")\n  .put(HtmlPiece.put(\"first_name\", firstName).bold().italic().big())\n  .put(HtmlPiece.put(\"age\", age).underline().color(\"#FF0000\"))\n  .format(new Formatter() {\n    @Override public CharSequence format(String input) {\n      return Html.fromHtml(input);\n    }\n  });\n```\n\nCode above will generate formatted text and can be used in **Android TextView** as follows:\n\n```java\ntextView.setText(formatted);\n```\n\n### Web\n\n```java\nCharSequence formatted = Kirai\n  .from(\"Hi {first_name}, your are {age} years old.\")\n  .put(HtmlPiece.put(\"first_name\", firstName).bold().italic().big())\n  .put(HtmlPiece.put(\"age\", age).underline().color(\"#FF0000\"))\n  .format();\n```\n\nCode above will generate text formatted with **HTML tags**.\n\n### Terminal\n\n```java\nCharSequence formatted = Kirai\n  .from(\"Hi {first_name}, your are {age} years old.\")\n  .put(TerminalPiece.put(\"first_name\", firstName).background(TerminalBgColor.DARK_GRAY).bold())\n  .put(TerminalPiece.put(\"age\", age).color(TerminalColor.CYAN).underline())\n  .format();\n```\n\nCode above will generate formatted text ready to display in **Unix terminal** as follows:\n\n```java\nSystem.out.println(formatted);\n```\n\ninstead of `TerminalColor` and `TerminalBgColor` enums we can pass color code as a string to `color(string)` method and it will work as well. We can use it for setting foreground and background color. For the reference of color codes take a look at http://misc.flogisoft.com/bash/tip_colors_and_formatting website.\n\nDownload\n--------\n\nYou can depend on the library through Maven:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.pwittchen.kirai\u003c/groupId\u003e\n    \u003cartifactId\u003elibrary\u003c/artifactId\u003e\n    \u003cversion\u003e1.4.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nor through Gradle:\n\n```groovy\ndependencies {\n  compile 'com.github.pwittchen.kirai:library:1.4.1'\n}\n```\n\nBuilding project\n----------------\n\nTo build project, run the following command:\n\n```\n./gradlew build\n```\n\nTests\n-----\n\nUnit Tests are available in `library/src/test` directory. They can be run from IntelliJ IDEA or CLI with Gradle Wrapper. Tests were written according to TDD methodology. They determine library specification and check if project is fault-tolerant. Code Coverage is monitored by [codecov.io](https://codecov.io/github/pwittchen/kirai?branch=master) integrated with Travis CI.\n\nTo execute tests, run the following command:\n\n```\n./gradlew test\n```\n\nTo generate code coverage report, run the following command:\n\n```\n./gradlew jacocoTestReport\n```\n\nAll reports are generated in `build/reports/` directory.\n\nStatic Code Analysis\n--------------------\n\nProject has Static Code Analysis configured in `build.gradle` file. It consists of CheckStyle, PMD and FindBugs.\n\nStatic Code Analysis can be executed with the following command:\n\n```\n./gradlew check\n```\n\nCode style\n----------\n\nCode style used in the project is called `Square` from Java Code Styles repository by Square available at: https://github.com/square/java-code-styles.\n\nLicense\n-------\n\n    Copyright 2015 Piotr Wittchen\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwittchen%2Fkirai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpwittchen%2Fkirai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpwittchen%2Fkirai/lists"}