mirror of
https://github.com/InsanusMokrassar/docs.git
synced 2025-12-21 21:55:35 +00:00
Compare commits
32 Commits
af5685678f
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| c95f3251bb | |||
| 7e886d5e65 | |||
| a6097e6784 | |||
| ec5bcaf058 | |||
| 2c97740abb | |||
| a2798c3b2e | |||
| 34abb664b9 | |||
| 1149abc79f | |||
| faa3573546 | |||
| 6e7cf1cb0e | |||
| c7e552ebb5 | |||
| 329a9ba310 | |||
| c74bafb4a3 | |||
| 256226044f | |||
|
|
1b02e8a7e4 | ||
| 7b0a171bd3 | |||
| 4410bb3b28 | |||
| 0931cbd97d | |||
| 228c7704f5 | |||
| 6377aefb6a | |||
| 3c433daa6b | |||
| a6c1aacf40 | |||
| 4dd90738ba | |||
| 68426c126d | |||
| ca7eedbb74 | |||
| 006f0b69d8 | |||
| df2812a04d | |||
| 9ec30af2ad | |||
| c8caed5b3a | |||
| c0e7ac5f27 | |||
| 55e8840a27 | |||
| 08871f9dc1 |
@@ -1,5 +1,11 @@
|
|||||||
{
|
{
|
||||||
"configurations": [
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "command",
|
||||||
|
"name": "Install",
|
||||||
|
"program": "poetry",
|
||||||
|
"args": ["install", "--no-root"],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "command",
|
"type": "command",
|
||||||
"name": "Rebuild",
|
"name": "Rebuild",
|
||||||
@@ -12,5 +18,12 @@
|
|||||||
"program": "poetry",
|
"program": "poetry",
|
||||||
"args": ["run", "mkdocs", "serve"],
|
"args": ["run", "mkdocs", "serve"],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "command",
|
||||||
|
"name": "Generate MicroUtils",
|
||||||
|
"program": "kotlin",
|
||||||
|
"args": ["../../generate_from_template.kts"],
|
||||||
|
"workingDir": "./docs/micro_utils/",
|
||||||
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
[](https://insanusmokrassar.github.io/krontab/)
|
[](https://insanusmokrassar.github.io/krontab/)
|
||||||
|
|
||||||
Library was created to give oppotunity to launch some things from time to time according to some schedule in
|
Library was created to give opportunity to launch some things from time to time according to some schedule in
|
||||||
runtime of applications.
|
runtime of applications.
|
||||||
|
|
||||||
## How to use
|
## How to use
|
||||||
@@ -77,7 +77,7 @@ doWhile("/5 * * * *") {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
An other version:
|
Another version:
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
doInfinity("/5 * * * *") {
|
doInfinity("/5 * * * *") {
|
||||||
@@ -166,7 +166,7 @@ coroutine is alive` and in fact executing will be stopped when coroutine became
|
|||||||
|
|
||||||
### KronScheduler as a Flow
|
### KronScheduler as a Flow
|
||||||
|
|
||||||
Any `KronScheduler`can e converted to a `Flow<DateTime` using extension `asFlow`:
|
Any `KronScheduler` can be converted to a `Flow<DateTime>` using extension `asFlow`:
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
val kronScheduler = buildSchedule {
|
val kronScheduler = buildSchedule {
|
||||||
@@ -178,7 +178,7 @@ val kronScheduler = buildSchedule {
|
|||||||
val flow = kronScheduler.asFlow()
|
val flow = kronScheduler.asFlow()
|
||||||
```
|
```
|
||||||
|
|
||||||
So, in this case any operations related to flow are available and it is expected that they will work correctly. For
|
So, in this case any operations related to flow are available, and it is expected that they will work correctly. For
|
||||||
example, it is possible to use this flow with `takeWhile`:
|
example, it is possible to use this flow with `takeWhile`:
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
@@ -191,7 +191,7 @@ flow.takeWhile {
|
|||||||
|
|
||||||
### Offsets
|
### Offsets
|
||||||
|
|
||||||
Offsets in this library works via passing parameter ending with `o` in any place after `month` config. Currently
|
Offsets in this library works via passing parameter ending with `o` in any place after `month` config. Currently,
|
||||||
there is only one format supported for offsets: minutes of offsets. To use time zones you will need to call `next`
|
there is only one format supported for offsets: minutes of offsets. To use time zones you will need to call `next`
|
||||||
method with `DateTimeTz` argument or `nextTimeZoned` method with any `KronScheduler` instance, but in case if this
|
method with `DateTimeTz` argument or `nextTimeZoned` method with any `KronScheduler` instance, but in case if this
|
||||||
scheduler is not instance of `KronSchedulerTz` it will work like you passed just `DateTime`.
|
scheduler is not instance of `KronSchedulerTz` it will work like you passed just `DateTime`.
|
||||||
@@ -211,4 +211,4 @@ Unlike original CRON, here week days:
|
|||||||
* Works as `AND`: cron date time will search first day which will pass requirement according all parameters including
|
* Works as `AND`: cron date time will search first day which will pass requirement according all parameters including
|
||||||
week days
|
week days
|
||||||
* You may use any related to numbers syntax with week days: `0-3w`, `0,1,2,3w`, etc.
|
* You may use any related to numbers syntax with week days: `0-3w`, `0,1,2,3w`, etc.
|
||||||
* Week days (like years and offsets) are optional and can be placed anywhere after `month`
|
* Week days (as well as years and offsets) are optional and can be placed anywhere after `month`
|
||||||
|
|||||||
42
docs/micro_utils/colors.ktstemplate.md
Normal file
42
docs/micro_utils/colors.ktstemplate.md
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
group=dev.inmo
|
||||||
|
artifact=micro_utils.colors.common
|
||||||
|
package=$group.$artifact
|
||||||
|
central_package=$group/$artifact
|
||||||
|
|
||||||
|
# Colors [](https://maven-badges.herokuapp.com/maven-central/${central_package})
|
||||||
|
|
||||||
|
* `Group`: `$group`
|
||||||
|
* `ArtifactId`: `$artifact`
|
||||||
|
|
||||||
|
Adding dependency:
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
implementation "$group:$artifact:latest"
|
||||||
|
```
|
||||||
|
|
||||||
|
> INFO:
|
||||||
|
>
|
||||||
|
> All the samples below will represent `HEXAColor` with `r==0xaa`, `g==0xff`, `b==0x00` and `a==0xff`
|
||||||
|
|
||||||
|
This package contains mainly one file: [HEXAColor](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.colors.common/-h-e-x-a-color/index.html). This file
|
||||||
|
contains unified color with HEXA format. It consumes `UInt` by default constructor and r/g/b/a parameters in other main constructors:
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
HEXAColor(0xaaff00ffu) // 0xRGBAu as UInt
|
||||||
|
HEXAColor(r = 0xaa, g = 0xff, b = 0x00, a = 0xff)
|
||||||
|
HEXAColor(r = 0xaa, g = 0xff, b = 0x00, aOfOne = 1f)
|
||||||
|
```
|
||||||
|
|
||||||
|
Besides, you may use one of converters:
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
HEXAColor.fromAhex(0xffaaff00u) // 0xARGBu as UInt
|
||||||
|
HEXAColor.parse("rgba(aa, ff, 00, ff)")
|
||||||
|
HEXAColor.parse("rgba(aa, ff, 00)")
|
||||||
|
HEXAColor.parse("#af0")
|
||||||
|
HEXAColor.parse("#af0f")
|
||||||
|
HEXAColor.parse("#aaff00")
|
||||||
|
HEXAColor.parse("#aaff00ff")
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
39
docs/micro_utils/colors.md
Normal file
39
docs/micro_utils/colors.md
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# Colors
|
||||||
|
|
||||||
|
[](https://maven-badges.herokuapp.com/maven-central/dev.inmo/micro_utils.colors.common)
|
||||||
|
|
||||||
|
* `Group`: `dev.inmo`
|
||||||
|
* `ArtifactId`: `micro_utils.colors.common`
|
||||||
|
|
||||||
|
Adding dependency:
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
implementation "dev.inmo:micro_utils.colors.common:latest"
|
||||||
|
```
|
||||||
|
|
||||||
|
> INFO:
|
||||||
|
>
|
||||||
|
> All the samples below will represent `HEXAColor` with `r==0xaa`, `g==0xff`, `b==0x00` and `a==0xff`
|
||||||
|
|
||||||
|
This package contains mainly one file: [HEXAColor](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.colors.common/-h-e-x-a-color/index.html). This file
|
||||||
|
contains unified color with HEXA format. It consumes `UInt` by default constructor and r/g/b/a parameters in other main constructors:
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
HEXAColor(0xaaff00ffu) // 0xRGBAu as UInt
|
||||||
|
HEXAColor(r = 0xaa, g = 0xff, b = 0x00, a = 0xff)
|
||||||
|
HEXAColor(r = 0xaa, g = 0xff, b = 0x00, aOfOne = 1f)
|
||||||
|
```
|
||||||
|
|
||||||
|
Besides, you may use one of converters:
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
HEXAColor.fromAhex(0xffaaff00u) // 0xARGBu as UInt
|
||||||
|
HEXAColor.parse("rgba(aa, ff, 00, ff)")
|
||||||
|
HEXAColor.parse("rgba(aa, ff, 00)")
|
||||||
|
HEXAColor.parse("#af0")
|
||||||
|
HEXAColor.parse("#af0f")
|
||||||
|
HEXAColor.parse("#aaff00")
|
||||||
|
HEXAColor.parse("#aaff00ff")
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -17,3 +17,183 @@ First of all, this library collection is oriented to use next technologies:
|
|||||||
> Me and the users of this library will try hard to keep its docs as actual as possible, but in case
|
> Me and the users of this library will try hard to keep its docs as actual as possible, but in case
|
||||||
> you will find some inconsistency of docs and library work (signatures, behaviour, API) you may write
|
> you will find some inconsistency of docs and library work (signatures, behaviour, API) you may write
|
||||||
> me directly in my [telegram](https://t.me/InsanusMokrassar)
|
> me directly in my [telegram](https://t.me/InsanusMokrassar)
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
flowchart LR
|
||||||
|
%% Project Build & Infrastructure
|
||||||
|
subgraph "Project Build & Infrastructure"
|
||||||
|
gradleWrapper("Gradle Wrapper & Plugins"):::buildInfra
|
||||||
|
CI("CI Workflows"):::buildInfra
|
||||||
|
templates("Gradle Templates"):::buildInfra
|
||||||
|
end
|
||||||
|
|
||||||
|
%% Core Utility Layer
|
||||||
|
subgraph "Core Utility Layer"
|
||||||
|
common("common"):::core
|
||||||
|
colors("colors"):::core
|
||||||
|
safe_wrapper("safe_wrapper"):::core
|
||||||
|
resources("resources"):::core
|
||||||
|
end
|
||||||
|
|
||||||
|
%% Feature-Specific Modules
|
||||||
|
subgraph "Feature-Specific Modules"
|
||||||
|
crypto("crypto"):::feature
|
||||||
|
mime_types("mime_types"):::feature
|
||||||
|
language_codes("language_codes"):::feature
|
||||||
|
matrix("matrix"):::feature
|
||||||
|
selector("selector"):::feature
|
||||||
|
transactions("transactions"):::feature
|
||||||
|
end
|
||||||
|
|
||||||
|
%% Asynchronous Helpers
|
||||||
|
subgraph "Asynchronous Helpers"
|
||||||
|
coroutines("coroutines"):::async
|
||||||
|
compose("coroutines/compose"):::async
|
||||||
|
end
|
||||||
|
|
||||||
|
%% Serialization Helpers
|
||||||
|
subgraph "Serialization Helpers"
|
||||||
|
base64("serialization/base64"):::serialization
|
||||||
|
encapsulator("serialization/encapsulator"):::serialization
|
||||||
|
mapper("serialization/mapper"):::serialization
|
||||||
|
typed_serializer("serialization/typed_serializer"):::serialization
|
||||||
|
end
|
||||||
|
|
||||||
|
%% Repository Abstractions
|
||||||
|
subgraph "Repository Abstractions"
|
||||||
|
repos_common("repos/common (API)"):::repos
|
||||||
|
repos_inmemory("repos/inmemory"):::repos
|
||||||
|
repos_cache("repos/cache"):::repos
|
||||||
|
repos_exposed("repos/exposed"):::repos
|
||||||
|
repos_ktor_client("repos/ktor/client"):::repos
|
||||||
|
repos_ktor_common("repos/ktor/common"):::repos
|
||||||
|
repos_ktor_server("repos/ktor/server"):::repos
|
||||||
|
end
|
||||||
|
|
||||||
|
%% Ktor Extensions
|
||||||
|
subgraph "Ktor Extensions"
|
||||||
|
ktor_common("ktor/common"):::ktor
|
||||||
|
ktor_client("ktor/client"):::ktor
|
||||||
|
ktor_server("ktor/server"):::ktor
|
||||||
|
end
|
||||||
|
|
||||||
|
%% Dependency Injection (Koin)
|
||||||
|
subgraph "Dependency Injection (Koin)"
|
||||||
|
koin_api("koin/src"):::di
|
||||||
|
koin_generator("koin/generator"):::di
|
||||||
|
end
|
||||||
|
|
||||||
|
%% KSP Code-Generation Modules
|
||||||
|
subgraph "KSP Code-Generation Modules"
|
||||||
|
ksp_classcasts("ksp/classcasts"):::ksp
|
||||||
|
ksp_sealed("ksp/sealed"):::ksp
|
||||||
|
ksp_variations("ksp/variations"):::ksp
|
||||||
|
ksp_generator("ksp/generator"):::ksp
|
||||||
|
end
|
||||||
|
|
||||||
|
%% Android UI Wrappers
|
||||||
|
subgraph "Android UI Wrappers"
|
||||||
|
alerts("android/alerts"):::android
|
||||||
|
pickers("android/pickers"):::android
|
||||||
|
recyclerview("android/recyclerview"):::android
|
||||||
|
smalltextfield("android/smalltextfield"):::android
|
||||||
|
end
|
||||||
|
|
||||||
|
%% Startup Plugins & Templates
|
||||||
|
subgraph "Startup Plugins & Templates"
|
||||||
|
startup_plugin("startup/plugin"):::startup
|
||||||
|
startup_launcher("startup/launcher"):::startup
|
||||||
|
startup_template("startup/template"):::startup
|
||||||
|
end
|
||||||
|
|
||||||
|
%% Dependencies Arrows
|
||||||
|
common -->|feeds into| crypto
|
||||||
|
common -->|feeds into| mime_types
|
||||||
|
common -->|feeds into| language_codes
|
||||||
|
common -->|feeds into| matrix
|
||||||
|
common -->|feeds into| selector
|
||||||
|
common -->|feeds into| transactions
|
||||||
|
|
||||||
|
common -->|feeds into| coroutines
|
||||||
|
coroutines -->|extends| compose
|
||||||
|
|
||||||
|
common -->|feeds into| base64
|
||||||
|
common -->|feeds into| encapsulator
|
||||||
|
common -->|feeds into| mapper
|
||||||
|
common -->|feeds into| typed_serializer
|
||||||
|
|
||||||
|
common -->|feeds into| repos_common
|
||||||
|
repos_common -->|implemented by| repos_inmemory
|
||||||
|
repos_common -->|implemented by| repos_cache
|
||||||
|
repos_common -->|implemented by| repos_exposed
|
||||||
|
repos_common -->|implemented by| repos_ktor_client
|
||||||
|
repos_common -->|implemented by| repos_ktor_common
|
||||||
|
repos_common -->|implemented by| repos_ktor_server
|
||||||
|
|
||||||
|
ktor_common -->|used by| ktor_client
|
||||||
|
ktor_common -->|used by| ktor_server
|
||||||
|
|
||||||
|
ksp_generator -->|used by| koin_generator
|
||||||
|
ksp_generator -->|used by| ksp_classcasts
|
||||||
|
ksp_generator -->|used by| ksp_sealed
|
||||||
|
ksp_generator -->|used by| ksp_variations
|
||||||
|
|
||||||
|
common -->|feeds into| alerts
|
||||||
|
common -->|feeds into| pickers
|
||||||
|
common -->|feeds into| recyclerview
|
||||||
|
common -->|feeds into| smalltextfield
|
||||||
|
|
||||||
|
%% Click Events
|
||||||
|
click templates "https://github.com/insanusmokrassar/microutils/tree/master/gradle/templates/"
|
||||||
|
click common "https://github.com/insanusmokrassar/microutils/tree/master/common/"
|
||||||
|
click colors "https://github.com/insanusmokrassar/microutils/tree/master/colors/"
|
||||||
|
click safe_wrapper "https://github.com/insanusmokrassar/microutils/tree/master/safe_wrapper/"
|
||||||
|
click resources "https://github.com/insanusmokrassar/microutils/tree/master/resources/"
|
||||||
|
click crypto "https://github.com/insanusmokrassar/microutils/tree/master/crypto/"
|
||||||
|
click mime_types "https://github.com/insanusmokrassar/microutils/tree/master/mime_types/"
|
||||||
|
click language_codes "https://github.com/insanusmokrassar/microutils/tree/master/language_codes/"
|
||||||
|
click matrix "https://github.com/insanusmokrassar/microutils/tree/master/matrix/"
|
||||||
|
click selector "https://github.com/insanusmokrassar/microutils/tree/master/selector/"
|
||||||
|
click transactions "https://github.com/insanusmokrassar/microutils/tree/master/transactions/"
|
||||||
|
click coroutines "https://github.com/insanusmokrassar/microutils/tree/master/coroutines/"
|
||||||
|
click compose "https://github.com/insanusmokrassar/microutils/tree/master/coroutines/compose/"
|
||||||
|
click base64 "https://github.com/insanusmokrassar/microutils/tree/master/serialization/base64/"
|
||||||
|
click encapsulator "https://github.com/insanusmokrassar/microutils/tree/master/serialization/encapsulator/"
|
||||||
|
click mapper "https://github.com/insanusmokrassar/microutils/tree/master/serialization/mapper/"
|
||||||
|
click typed_serializer "https://github.com/insanusmokrassar/microutils/tree/master/serialization/typed_serializer/"
|
||||||
|
click repos_common "https://github.com/insanusmokrassar/microutils/tree/master/repos/common/"
|
||||||
|
click repos_inmemory "https://github.com/insanusmokrassar/microutils/tree/master/repos/inmemory/"
|
||||||
|
click repos_cache "https://github.com/insanusmokrassar/microutils/tree/master/repos/cache/"
|
||||||
|
click repos_exposed "https://github.com/insanusmokrassar/microutils/tree/master/repos/exposed/"
|
||||||
|
click repos_ktor_client "https://github.com/insanusmokrassar/microutils/tree/master/repos/ktor/client/"
|
||||||
|
click repos_ktor_common "https://github.com/insanusmokrassar/microutils/tree/master/repos/ktor/common/"
|
||||||
|
click repos_ktor_server "https://github.com/insanusmokrassar/microutils/tree/master/repos/ktor/server/"
|
||||||
|
click koin_api "https://github.com/insanusmokrassar/microutils/tree/master/koin/src/"
|
||||||
|
click koin_generator "https://github.com/insanusmokrassar/microutils/tree/master/koin/generator/"
|
||||||
|
click ksp_classcasts "https://github.com/insanusmokrassar/microutils/tree/master/ksp/classcasts/"
|
||||||
|
click ksp_sealed "https://github.com/insanusmokrassar/microutils/tree/master/ksp/sealed/"
|
||||||
|
click ksp_variations "https://github.com/insanusmokrassar/microutils/tree/master/ksp/variations/"
|
||||||
|
click ksp_generator "https://github.com/insanusmokrassar/microutils/tree/master/ksp/generator/"
|
||||||
|
click alerts "https://github.com/insanusmokrassar/microutils/tree/master/android/alerts/"
|
||||||
|
click pickers "https://github.com/insanusmokrassar/microutils/tree/master/android/pickers/"
|
||||||
|
click recyclerview "https://github.com/insanusmokrassar/microutils/tree/master/android/recyclerview/"
|
||||||
|
click smalltextfield "https://github.com/insanusmokrassar/microutils/tree/master/android/smalltextfield/"
|
||||||
|
click startup_plugin "https://github.com/insanusmokrassar/microutils/tree/master/startup/plugin/"
|
||||||
|
click startup_launcher "https://github.com/insanusmokrassar/microutils/tree/master/startup/launcher/"
|
||||||
|
click startup_template "https://github.com/insanusmokrassar/microutils/tree/master/startup/template/"
|
||||||
|
|
||||||
|
%% Styles
|
||||||
|
%% classDef buildInfra fill:#eee,stroke:#666,stroke-width:1px;
|
||||||
|
%% classDef core fill:#cce5ff,stroke:#004085,stroke-width:1px;
|
||||||
|
%% classDef feature fill:#e2e3e5,stroke:#636f83,stroke-width:1px;
|
||||||
|
%% classDef async fill:#d1ecf1,stroke:#0c5460,stroke-width:1px;
|
||||||
|
%% classDef serialization fill:#fff3cd,stroke:#856404,stroke-width:1px;
|
||||||
|
%% classDef repos fill:#d4edda,stroke:#155724,stroke-width:1px;
|
||||||
|
%% classDef ktor fill:#ffe5b4,stroke:#ff8c00,stroke-width:1px;
|
||||||
|
%% classDef di fill:#f5c6cb,stroke:#721c24,stroke-width:1px;
|
||||||
|
%% classDef ksp fill:#f8d7da,stroke:#721c24,stroke-width:1px;
|
||||||
|
%% classDef android fill:#e2e7ec,stroke:#1f2a36,stroke-width:1px;
|
||||||
|
%% classDef startup fill:#f0f3bd,stroke:#a2a04f,stroke-width:1px;
|
||||||
|
```
|
||||||
|
|
||||||
|
Generated with [gitdiagram](https://gitdiagram.com/insanusmokrassar/microutils) and edited then
|
||||||
|
|||||||
119
docs/micro_utils/repos/index.md
Normal file
119
docs/micro_utils/repos/index.md
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
# Repos
|
||||||
|
|
||||||
|
Repositories in this library are unified interfaces to work with different types of standard repos:
|
||||||
|
|
||||||
|
* CRUD (create/read/update/delete)
|
||||||
|
* Key-value
|
||||||
|
* Key-value**s**
|
||||||
|
|
||||||
|
## CRUD
|
||||||
|
|
||||||
|
Default interface for any `CRUD`-oriented realization of repositories. This type of repos separated to three interfaces:
|
||||||
|
|
||||||
|
* [ReadCRUDRepo](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-read-c-r-u-d-repo/index.html)
|
||||||
|
* [WriteCRUDRepo](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-write-c-r-u-d-repo/index.html)
|
||||||
|
* [CRUDRepo](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-c-r-u-d-repo/index.html)
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
flowchart TB
|
||||||
|
ReadCRUDRepo --> CRUDRepo
|
||||||
|
WriteCRUDRepo --> CRUDRepo
|
||||||
|
```
|
||||||
|
|
||||||
|
`CRUDRepo` extends both `ReadCRUDRepo` and `WriteCRUDRepo`.
|
||||||
|
|
||||||
|
CRUD repos __do not__ support forced placing of data by id when data is not in repo. That means, that you can't set data in repo by id
|
||||||
|
which absent in the repository.
|
||||||
|
|
||||||
|
### `ReadCRUDRepo`
|
||||||
|
|
||||||
|
Contains read-only operations, such as [getById](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-read-c-r-u-d-repo/get-by-id.html),
|
||||||
|
[contains](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-read-c-r-u-d-repo/contains.html). This interface can't be observed because of it does not suppose
|
||||||
|
any mutable operation.
|
||||||
|
|
||||||
|
### `WriteCRUDRepo`
|
||||||
|
|
||||||
|
Contains write-only operations, such as [create](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-write-c-r-u-d-repo/create.html),
|
||||||
|
[update](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-write-c-r-u-d-repo/update.html). This interface can be observed via its flows:
|
||||||
|
|
||||||
|
* [newObjectsFlow](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-write-c-r-u-d-repo/new-objects-flow.html) for newely
|
||||||
|
[create](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-write-c-r-u-d-repo/create.html)d objects
|
||||||
|
* [updatedObjectsFlow](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-write-c-r-u-d-repo/updated-objects-flow.html) for old
|
||||||
|
[update](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-write-c-r-u-d-repo/update.html)d objects
|
||||||
|
* [deletedObjectsIdsFlow](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-write-c-r-u-d-repo/deleted-objects-ids-flow.html) for
|
||||||
|
[delete](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-write-c-r-u-d-repo/delete-by-id.html)d objects
|
||||||
|
|
||||||
|
> INFO:
|
||||||
|
>
|
||||||
|
> By default, all mutating operations consumes `List`s of data (`List<New>` for `create`, `List<Pair<Id, New>>` for `update` and `List<Id>` for delete),
|
||||||
|
> but all they have their extension function-variations with one/two args (like `create` with `New` arg)
|
||||||
|
|
||||||
|
* `create` operation consumes list of `New` variants of object and produces `Registered`s list. In most cases, `Registered` variant of object should have
|
||||||
|
`Id` of registered object, but it is not required for repo.
|
||||||
|
* `update` operation consumes list of pairs with `Id` and `New` objects and produces list of `Registered` objects.
|
||||||
|
* `deleteById` operation consumes list of `Id`s and do not consume anything except of notifying via `deletedObjectsIdsFlow`.
|
||||||
|
|
||||||
|
## KeyValue
|
||||||
|
|
||||||
|
Key-value repos has been created to support work with classic key-value stores, where keys are unique across all the repo when values are not unique.
|
||||||
|
As well as all the others types of repos, this one have two basic types:
|
||||||
|
[ReadKeyValueRepo](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-read-key-value-repo/index.html) and
|
||||||
|
[WriteKeyValueRepo](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-write-key-value-repo/index.html)
|
||||||
|
|
||||||
|
### ReadKeyValueRepo
|
||||||
|
|
||||||
|
Read repo provides functions like: [contains](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-read-key-value-repo/contains.html),
|
||||||
|
[get](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-read-key-value-repo/get.html) or
|
||||||
|
[values](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-read-key-value-repo/values.html).
|
||||||
|
|
||||||
|
### WritekeyValueRepo
|
||||||
|
|
||||||
|
Contains write-only operations. This interface can be observed via its flows:
|
||||||
|
|
||||||
|
* [onNewValue](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-write-key-value-repo/on-new-value.html) to retrieve newely set values and keys
|
||||||
|
* [onValueRemoved](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-write-key-value-repo/on-value-removed.html) for the values removed from repo
|
||||||
|
|
||||||
|
> INFO:
|
||||||
|
>
|
||||||
|
> By default, all mutating operations consumes some collections. For example, [set](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-write-key-value-repo/set.html)
|
||||||
|
> require `Map` with `Key`s and `Value`s and do not returns anything. Instead, it will throw notification via `onNewValue` flow
|
||||||
|
>
|
||||||
|
> All the methods on `WriteKeyValueRepo` have their variances with `pairs` (for set) or plain `vararg`s.
|
||||||
|
|
||||||
|
* `set` operation consumes map of `Key`s and their `Value`s, set them and produces updates via `onNewValue`
|
||||||
|
* `unset` operation consumes list of `Key`s, removing `Value` by `Key` and produces updates via `onValueRemoved`
|
||||||
|
* `unsetWithValues` consumes list of `Value`s, removing all `Key`s with the `Value`s equal to one of the input `Value`s, and then produces updates via `onValueRemoved`
|
||||||
|
|
||||||
|
## KeyValues
|
||||||
|
|
||||||
|
This type of repos contains muliple `Value`s by their unique `Key`. It is not guaranteed, that `Value`s list by any `Key` will contains only unique values,
|
||||||
|
but in most cases `Value`s list will not contains copies/same objects.
|
||||||
|
|
||||||
|
### [ReadKeyValuesRepo](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-read-key-values-repo/index.html)
|
||||||
|
|
||||||
|
Contains operations for work with value/values getting and checking. For example:
|
||||||
|
[count](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-read-key-values-repo/count.html) for checking of amount of all values in repo
|
||||||
|
or values by key; [get](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-read-key-values-repo/get.html) for getting of values by
|
||||||
|
`pagination`.
|
||||||
|
|
||||||
|
### [WriteKeyValuesRepo](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-write-key-values-repo/index.html)
|
||||||
|
|
||||||
|
Contains write-only operations. This interface can be observed via its flows:
|
||||||
|
|
||||||
|
* [onNewValue](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-write-key-values-repo/on-new-value.html) will pass `Key` and `Value` when `Value` has been added to the `Key`
|
||||||
|
* [onValueRemoved](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-write-key-values-repo/on-value-removed.html) will pass `Key` and `Value` when `Value` has been removed for the `Key`
|
||||||
|
* [onDataCleared](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-write-key-values-repo/on-data-cleared.html) will pass `Key` when **all** its values has been
|
||||||
|
removed by the `clear` operation
|
||||||
|
|
||||||
|
> INFO:
|
||||||
|
>
|
||||||
|
> In difference with other repos, not all the methods of write key values repo require collections.
|
||||||
|
>
|
||||||
|
> All the methods on `WriteKeyValuesRepo` have their variances with `pairs` (for set) or plain `vararg`s.
|
||||||
|
|
||||||
|
* `add` will add `Value`s to their `Key`s without any removing of data
|
||||||
|
* `clear` removes all `Value`s by `Key` and `Key` itself from repo
|
||||||
|
* `clearWithValue` removes all `Value` with full clear of all data by `Key`s with incoming `Value`
|
||||||
|
* `remove` consumes `Map` of `Key`s and the `Value`s which should be removed for each `Key`
|
||||||
|
* `removeWithValue` will remove only `Value` from all `Key`s collections without their full wipe
|
||||||
|
* `set` consumes `Map` of `Key`s and the `Value`s and will **rewrite** currently exists list of `Value`s and set the `Value`s for their `Key`
|
||||||
20
docs/micro_utils/repos/inmemory.md
Normal file
20
docs/micro_utils/repos/inmemory.md
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# In memory
|
||||||
|
|
||||||
|
In memory realizations contains several simple variants:
|
||||||
|
|
||||||
|
* [MapCRUDRepo](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-map-c-r-u-d-repo/index.html)
|
||||||
|
* [MapKeyValueRepo](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-map-key-value-repo/index.html)
|
||||||
|
* [MapKeyValuesRepo](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-map-key-values-repo/index.html)
|
||||||
|
|
||||||
|
Each realization contains `Write` and `Read` parents.
|
||||||
|
|
||||||
|
There are several important moments:
|
||||||
|
|
||||||
|
## [WriteMapCRUDRepo](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-write-map-c-r-u-d-repo/index.html) (and [MapCRUDRepo](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-map-c-r-u-d-repo/index.html))
|
||||||
|
|
||||||
|
It is an abstract repo with abstract functions: `updateObject` and `createObject`. Both functions require from realization to create `Registered` variant from incoming data and
|
||||||
|
both will be called within repo [locker.withWriteLock](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.coroutines/with-write-lock.html).
|
||||||
|
|
||||||
|
You may use functions [MapCRUDRepo](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-map-c-r-u-d-repo.html) with
|
||||||
|
passing the callbacks `updateObject` and `createObject` which will be used in their realizations of default [MapCRUDRepo](https://microutils.inmo.dev/micro_utils.dokka/dev.inmo.micro_utils.repos/-map-c-r-u-d-repo/index.html)
|
||||||
|
variant
|
||||||
95
docs/micro_utils/startup.md
Normal file
95
docs/micro_utils/startup.md
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
# Startup
|
||||||
|
|
||||||
|
[](https://github.com/InsanusMokrassar/MicroUtils)
|
||||||
|
|
||||||
|
* **Plugins Package**: `dev.inmo:micro_utils.startup.plugin`
|
||||||
|
* **Launcher Package**: `dev.inmo:micro_utils.startup.launcher`
|
||||||
|
|
||||||
|
This package contains unified simple `Plugin`/`Launcher` tools for separating of your apps parts
|
||||||
|
|
||||||
|
Launching logic:
|
||||||
|
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
flowchart TB
|
||||||
|
StartLauncherPlugin.startAsync
|
||||||
|
StartLauncherPlugin.startAsync --> KoinInit["Koin.init"]
|
||||||
|
KoinInit --> StartLauncherPlugin.setupDI
|
||||||
|
|
||||||
|
|
||||||
|
subgraph StartLauncherPlugin.setupDI
|
||||||
|
direction LR
|
||||||
|
AddDefaultDependencies["Default dependencies: config as JsonObject, config as object, CoroutineScope, Json"]
|
||||||
|
SubPluginsSetupDI["Calling setupDI in subplugins"]
|
||||||
|
AddDefaultDependencies --> SubPluginsSetupDI
|
||||||
|
end
|
||||||
|
|
||||||
|
StartLauncherPlugin.setupDI --> startKoin
|
||||||
|
startKoin --> StartLauncherPlugin.startPlugin
|
||||||
|
|
||||||
|
subgraph StartLauncherPlugin.startPlugin
|
||||||
|
direction LR
|
||||||
|
LaunchSubplugins["Asynchronously (in CoroutineScope from Koin) start subplugins"]
|
||||||
|
end
|
||||||
|
|
||||||
|
StartLauncherPlugin.startPlugin --> ReturnKoinAppAndLaunchJob["Return koinApp and laucnhing job"]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Plugin
|
||||||
|
|
||||||
|
To define plugin, you must use `StartPlugin` as supertype for your plugin. Restrictions are simple: plugins must be an `object` or `class` with empty constructor. Basic sample is here:
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
object YourPlugin : StartPlugin {
|
||||||
|
// Body of your plugin
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Each plugin may contains to parts:
|
||||||
|
|
||||||
|
* `setupDI` function to set up DI part
|
||||||
|
* `startPlugin` function to start plugin
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
object YourPlugin : StartPlugin {
|
||||||
|
override fun Module.setupDI(config: JsonObject) {
|
||||||
|
// here you may setup any DI content you wish to be available in context of current Koin module
|
||||||
|
}
|
||||||
|
override fun startPlugin(koin: Koin) {
|
||||||
|
// all staff from setupDI and the same function of other plugins is available in koin
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Launcher
|
||||||
|
|
||||||
|
Basically, launcher module can be used to start application directly from `gradle`. Let's imagine you have this gradle groovy config:
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
plugins {
|
||||||
|
id 'org.jetbrains.kotlin.jvm'
|
||||||
|
id "org.jetbrains.kotlin.plugin.serialization"
|
||||||
|
id 'application'
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
// kotlin and other dependencies
|
||||||
|
implementation ("dev.inmo:micro_utils.startup.launcher:$latest_version")
|
||||||
|
}
|
||||||
|
|
||||||
|
application {
|
||||||
|
mainClassName = 'dev.inmo.micro_utils.startup.launcher.MainKt'
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
You will be able to run your project with gradle command `./gradlew run --args="path/to/config.json"`. `config.json` must contains something like:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
"dev.inmo.micro_utils.startup.launcher.HelloWorldPlugin"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
In current case you will see in logger different logs about launching including log from `HelloWorldPlugin` with text `Hello world`.
|
||||||
@@ -115,7 +115,40 @@ Initialization is different on the platforms, so, lets take a look at each one.
|
|||||||
In `JavaScript` it looks like:
|
In `JavaScript` it looks like:
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
initNavigation(
|
initNavigation<NavigationNodeDefaultConfig>(
|
||||||
|
ConfigHolder.Chain( // (1)
|
||||||
|
ConfigHolder.Node( // (2)
|
||||||
|
MainConfig(), // (3)
|
||||||
|
null, // (4)
|
||||||
|
listOf() // (5)
|
||||||
|
),
|
||||||
|
),
|
||||||
|
configsRepo = CookiesNavigationConfigsRepo( // (6)
|
||||||
|
Json {
|
||||||
|
ignoreUnknownKeys = true
|
||||||
|
serializersModule = SerializersModule {
|
||||||
|
polymorphic(NavigationNodeDefaultConfig::class, MainConfig::class, MainConfig.serializer()) // (7)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ConfigHolder.serializer(NavigationNodeDefaultConfig::class.serializer())
|
||||||
|
),
|
||||||
|
dropRedundantChainsOnRestore = true, // (8)
|
||||||
|
nodesFactory = MainNodeFactory, // (9)
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
1. Creating of default root chain config holder. It must be root chain because of the chain work with statuses changes
|
||||||
|
2. Creating of default root node config holder. This type contains config of the first node, its subnode and subchains lists
|
||||||
|
3. Default root config
|
||||||
|
4. Subnode of root node. In this case it is `null`, but can be any `ConfigHolder.Node`
|
||||||
|
5. Subchains of default root node
|
||||||
|
6. Configurations changes repo saver. By default it is `cookies` (`localStorage`) store
|
||||||
|
7. Register config for serialization to let configs repo serializer to know how to serialize `MainConfig`
|
||||||
|
8. Flag that the chains without any node will be dropped automatically
|
||||||
|
9. In fact here can be factory aggregator, for example:
|
||||||
|
```kotlin
|
||||||
|
val factories: List<NavigationNodeFactory<NavigationNodeDefaultConfig>>
|
||||||
|
NavigationNodeFactory<NavigationNodeDefaultConfig> { chainHolder, config ->
|
||||||
|
factories.firstNotNullOfOrNull { it.createNode(chainHolder, config) }
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -9,8 +9,10 @@
|
|||||||
|
|
||||||
Plugin is a partially independent part of bot. Plugin have several parts:
|
Plugin is a partially independent part of bot. Plugin have several parts:
|
||||||
|
|
||||||
* `setupDI` - this method should be used to configure DI part of module
|
* `setupBotClient` - method to configure telegram bot in case you need it. Called synchronously when `TelegramBot`
|
||||||
* `setupBotPlugin` - method to start/configure your bot actions
|
initializing in `single` in `setupDI` of `PlaguBot`
|
||||||
|
* `setupBotPlugin` - method to start/configure your **bot** actions. Called asynchronously in `buildBehaviourWithFSM`
|
||||||
|
in `startPlugin` of `PlaguBot`
|
||||||
|
|
||||||
Plugin realization should be an `object` or `class` with empty constructor.
|
Plugin realization should be an `object` or `class` with empty constructor.
|
||||||
|
|
||||||
@@ -20,6 +22,11 @@ Most important of bot is `main` function (full reference: `dev.inmo.plagubot.App
|
|||||||
|
|
||||||
Bot is initializing with the next algorithm:
|
Bot is initializing with the next algorithm:
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**OLD**
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
flowchart TB
|
flowchart TB
|
||||||
main["Main"]
|
main["Main"]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# TelegramBotAPI
|
# TelegramBotAPI
|
||||||
|
|
||||||
[](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#december-29-2023)
|
[](https://central.sonatype.com/artifact/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#april-11-2025)
|
||||||
|
|
||||||
<!--- [](https://t.me/ktgbotapi) --->
|
<!--- [](https://t.me/ktgbotapi) --->
|
||||||
|
|
||||||
|
|||||||
@@ -66,3 +66,62 @@ bot.buildBehaviour {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Long polling
|
||||||
|
|
||||||
|
In case you wish to start long polling, you have two options:
|
||||||
|
|
||||||
|
* Start long polling with `buildBehaviour` additional functions
|
||||||
|
* Start long polling from using the result of `buildBehaviour`
|
||||||
|
|
||||||
|
> NOTE: **More info**
|
||||||
|
>
|
||||||
|
> More info about updates retrieving you may read at the [Long Polling](../updates/long-polling.md) and [Webhooks](../updates/webhooks.md)
|
||||||
|
> articles
|
||||||
|
|
||||||
|
|
||||||
|
### Long polling from `buildBehaviour`
|
||||||
|
|
||||||
|
With prepared bot:
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
val bot = telegramBot("TOKEN")
|
||||||
|
|
||||||
|
bot.buildBehaviourWithLongPolling {
|
||||||
|
onCommand(
|
||||||
|
"start",
|
||||||
|
requireOnlyCommandInMessage = true // it is default, but you can overwrite it with `requireOnlyCommandInMessage = false`
|
||||||
|
) {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Without prepared bot:
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
telegramBotWithBehaviourAndLongPolling("TOKEN") {
|
||||||
|
onCommand(
|
||||||
|
"start",
|
||||||
|
requireOnlyCommandInMessage = true // it is default, but you can overwrite it with `requireOnlyCommandInMessage = false`
|
||||||
|
) {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Long polling from the result of behaviour building
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
val bot = telegramBot("TOKEN")
|
||||||
|
val rootContext = bot.buildBehaviour {
|
||||||
|
onCommand(
|
||||||
|
"start",
|
||||||
|
requireOnlyCommandInMessage = true // it is default, but you can overwrite it with `requireOnlyCommandInMessage = false`
|
||||||
|
) {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bot.longPolling(rootContext) // start listening updates
|
||||||
|
```
|
||||||
|
|||||||
111
generate_from_template.kts
Normal file
111
generate_from_template.kts
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
import kotlin.collections.LinkedHashSet
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
val templateEnding = Regex("\\.ktstemplate(\\.[^\\.]*)*$")
|
||||||
|
val templateOnlyEnding = Regex("\\.ktstemplate")
|
||||||
|
val singleArgumentRegex = Regex("^[\\w\\d]+$")
|
||||||
|
val splitterRegex = Regex("[ ]*=[ ]*")
|
||||||
|
|
||||||
|
sealed interface Mode {
|
||||||
|
fun filesList(folder: File): Sequence<File>
|
||||||
|
|
||||||
|
data object Recursive : Mode {
|
||||||
|
override fun filesList(folder: File): Sequence<File> {
|
||||||
|
return sequence {
|
||||||
|
val folders = mutableListOf<File>()
|
||||||
|
folders.add(folder)
|
||||||
|
while (folders.isNotEmpty()) {
|
||||||
|
val currentFolder = folders.removeAt(0)
|
||||||
|
currentFolder.listFiles().toList().forEach {
|
||||||
|
when {
|
||||||
|
it.isFile -> yield(it)
|
||||||
|
it.isDirectory -> folders.add(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data object Plain : Mode {
|
||||||
|
override fun filesList(folder: File): Sequence<File> {
|
||||||
|
return sequence {
|
||||||
|
folder.listFiles().forEach {
|
||||||
|
yield(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var mode: Mode = Mode.Recursive
|
||||||
|
|
||||||
|
val folders = args.mapNotNull {
|
||||||
|
if (it.startsWith("-")) { // assume some arg
|
||||||
|
when (it) {
|
||||||
|
"--plain" -> mode = Mode.Plain
|
||||||
|
"--recursive" -> mode = Mode.Recursive
|
||||||
|
"--help" -> {
|
||||||
|
println("[...pathnames] [--recursive] [--plain]")
|
||||||
|
println("...pathnames - Pass any count of folder or files paths")
|
||||||
|
println("--recursive - (default) Use recursive visiting of folders for each path in pathnames")
|
||||||
|
println("--plain - (default) Use plain (non-recursive) visiting of folders for each path in pathnames")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
null
|
||||||
|
} else {
|
||||||
|
File(it)
|
||||||
|
}
|
||||||
|
}.ifEmpty {
|
||||||
|
listOf(File("./"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun String.replaceVariables(variables: Map<String, String>): String {
|
||||||
|
var currentLine = this
|
||||||
|
variables.forEach { (k, v) ->
|
||||||
|
currentLine = currentLine.replace("\${${k}}", v)
|
||||||
|
if (k.matches(singleArgumentRegex)) {
|
||||||
|
currentLine = currentLine.replace("\$${k}", v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return currentLine
|
||||||
|
}
|
||||||
|
|
||||||
|
fun generateFromTemplate(folder: File, file: File) {
|
||||||
|
val targetFile = File(folder, file.name.replace(templateOnlyEnding, ""))
|
||||||
|
|
||||||
|
val variables = mutableMapOf<String, String>()
|
||||||
|
var writeVariables = true
|
||||||
|
var text = ""
|
||||||
|
|
||||||
|
file.readLines().forEach { line ->
|
||||||
|
when {
|
||||||
|
writeVariables && line.startsWith("#") -> {
|
||||||
|
writeVariables = false
|
||||||
|
}
|
||||||
|
writeVariables -> {
|
||||||
|
val splitted = line.split(splitterRegex)
|
||||||
|
if (splitted.size > 1) {
|
||||||
|
val k = splitted[0]
|
||||||
|
val v = splitted[1].replaceVariables(variables)
|
||||||
|
variables[k] = v
|
||||||
|
}
|
||||||
|
return@forEach
|
||||||
|
}
|
||||||
|
}
|
||||||
|
text += line.let {
|
||||||
|
line.replaceVariables(variables) + "\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
targetFile.writeText(text)
|
||||||
|
println("${targetFile.absolutePath} has been recreated")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.none { it == "--help" }) {
|
||||||
|
folders.forEach { folder ->
|
||||||
|
mode.filesList(folder).forEach { file ->
|
||||||
|
if (file.name.contains(templateEnding)) {
|
||||||
|
generateFromTemplate(file.parentFile, file)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,7 +10,13 @@ nav:
|
|||||||
- Home: 'index.md'
|
- Home: 'index.md'
|
||||||
- 'MicroUtils':
|
- 'MicroUtils':
|
||||||
- 'micro_utils/index.md'
|
- 'micro_utils/index.md'
|
||||||
|
- KDocs: 'https://microutils.inmo.dev/index.html'
|
||||||
- 'micro_utils/resources.md'
|
- 'micro_utils/resources.md'
|
||||||
|
- 'micro_utils/startup.md'
|
||||||
|
- 'micro_utils/colors.md'
|
||||||
|
- 'Repos':
|
||||||
|
- 'micro_utils/repos/index.md'
|
||||||
|
- 'micro_utils/repos/inmemory.md'
|
||||||
- 'Telegram Bot API':
|
- 'Telegram Bot API':
|
||||||
- 'tgbotapi/index.md'
|
- 'tgbotapi/index.md'
|
||||||
- KDocs: 'https://tgbotapi.inmo.dev'
|
- KDocs: 'https://tgbotapi.inmo.dev'
|
||||||
@@ -49,6 +55,7 @@ nav:
|
|||||||
- 'kslog/setup.md'
|
- 'kslog/setup.md'
|
||||||
- 'kslog/logging.md'
|
- 'kslog/logging.md'
|
||||||
- 'Navigation':
|
- 'Navigation':
|
||||||
|
- Sample: 'https://insanusmokrassar.github.io/navigation/'
|
||||||
- 'navigation/index.md'
|
- 'navigation/index.md'
|
||||||
- 'navigation/getting-started.md'
|
- 'navigation/getting-started.md'
|
||||||
- 'Services':
|
- 'Services':
|
||||||
@@ -85,7 +92,7 @@ theme:
|
|||||||
- content.action.view
|
- content.action.view
|
||||||
- content.code.annotate
|
- content.code.annotate
|
||||||
- content.code.copy
|
- content.code.copy
|
||||||
# - content.tabs.link
|
- content.tabs.link
|
||||||
- content.tooltips
|
- content.tooltips
|
||||||
# - header.autohide
|
# - header.autohide
|
||||||
# - navigation.expand
|
# - navigation.expand
|
||||||
|
|||||||
868
poetry.lock
generated
868
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -6,13 +6,13 @@ authors = ["InsanusMokrassar"]
|
|||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.8"
|
python = "^3.8"
|
||||||
mkdocs = "^1.5.3"
|
mkdocs = "^1.6.1"
|
||||||
markdown-callouts = "^0.3.0"
|
markdown-callouts = "^0.4.0"
|
||||||
mkdocs-autorefs = "^0.5.0"
|
mkdocs-autorefs = "^1.2.0"
|
||||||
mkdocs-include-dir-to-nav = "^1.2.0"
|
mkdocs-include-dir-to-nav = "^1.2.0"
|
||||||
mkdocs-material = "^9.5.1"
|
mkdocs-material = "^9.6.17"
|
||||||
pymdown-extensions = "^10.4"
|
pymdown-extensions = "^10.6.1"
|
||||||
mkdocs-mermaid2-plugin = "^1.1.1"
|
mkdocs-mermaid2-plugin = "^1.2.1"
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.poetry.dev-dependencies]
|
||||||
|
|
||||||
|
|||||||
6
renovate.json
Normal file
6
renovate.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
|
"extends": [
|
||||||
|
"config:recommended"
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user