refactor: 🔨 changed feature names
This commit is contained in:
parent
14d80d71de
commit
7235281915
1
.github/img/icon-has-submodules.svg
vendored
Normal file
1
.github/img/icon-has-submodules.svg
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 32"><path d="M16,6A4,4,0,0,0,8,6H0v6a4,4,0,0,1,4,4,4,4,0,0,1-4,4v6H8a4,4,0,0,0,8,0h8V6Z" style="fill:#ea80fc"/><path d="M48,12V6H40a4,4,0,0,1-8,0H24v6a4,4,0,0,0,0,8v6h8a4,4,0,0,1,8,0h8V20a4,4,0,0,0,0-8Z" style="fill:#18ffff"/></svg>
|
||||||
|
After Width: | Height: | Size: 288 B |
11
.github/img/logo-cli.svg
vendored
Normal file
11
.github/img/logo-cli.svg
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 142 119.78369">
|
||||||
|
<style>
|
||||||
|
.a { fill: #000000; }
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
.a { fill: #ffffff; }
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<path class="a" d="M4.91962,1.516H0V0H20.42877V61.6416h4.6695v1.51648H.3335V61.6416H4.91962ZM32.68567,58.60962q-5.33725-5.3865-5.33649-15.45264,0-10.06072,5.71161-15.49371,5.71014-5.432,16.051-5.432,10.33767,0,15.42578,5.01056Q69.62248,32.25306,69.624,42.5265,69.624,63.999,48.44489,64,38.02069,64,32.68567,58.60962ZM43.35858,39.83124v6.56811q0,9.18109.54187,11.03144a18.93828,18.93828,0,0,0,1.12549,3.032,3.54886,3.54886,0,0,0,3.58575,2.02167q3.252,0,4.25214-3.79071.751-2.69324.75079-12.12592v-7.1575a57.79357,57.79357,0,0,0-.87579-11.916q-.87543-3.74541-4.04382-3.74713a4.16107,4.16107,0,0,0-2.96,1.05243,6.4872,6.4872,0,0,0-1.62616,3.495A64.699,64.699,0,0,0,43.35858,39.83124ZM137.33051,61.6416V0H116.90173V1.516h4.91962V61.6416h-4.58618v1.51648H142V61.6416Zm-59.36792-3.032Q72.62468,53.2231,72.62518,43.157q0-10.06072,5.7116-15.49371,5.71161-5.432,16.051-5.432,10.33839,0,15.42669,5.01056,5.08347,5.01123,5.08538,15.28473Q114.8999,63.999,93.721,64q-10.423,0-15.75841-5.39038ZM88.6355,39.83124v6.56811q0,9.18109.541,11.03144a18.93282,18.93282,0,0,0,1.12641,3.032,3.54715,3.54715,0,0,0,3.58477,2.02167q3.25276,0,4.25269-3.79071.75165-2.69324.75122-12.12592h.00006v-7.1575a57.81892,57.81892,0,0,0-.87634-11.916q-.87533-3.74541-4.04425-3.74713a4.16011,4.16011,0,0,0-2.95954,1.05243,6.48466,6.48466,0,0,0-1.62567,3.495A64.70833,64.70833,0,0,0,88.6355,39.83124Z" />
|
||||||
|
<path class="a" d="M0,80.25H142V78H0Z" />
|
||||||
|
<path class="a" d="M94.54443,99.29932a2.3565,2.3565,0,0,0,.6631-1.6836v-.98536a2.33921,2.33921,0,0,0-.6631-1.70018,4.44567,4.44567,0,0,0-4.72656,0,2.33846,2.33846,0,0,0-.66211,1.70018v.98536a2.35572,2.35572,0,0,0,.66211,1.6836A4.35366,4.35366,0,0,0,94.54443,99.29932Zm-46.23925,7.54785a3.46851,3.46851,0,0,1,2.66894-1.00293,3.19824,3.19824,0,0,1,2.19336.67969,5.16812,5.16812,0,0,1,1.24072,1.70018l3.876-2.10839a7.58028,7.58028,0,0,0-2.669-3.11036,8.21,8.21,0,0,0-4.64111-1.17285,10.26889,10.26889,0,0,0-3.689.62891,7.50149,7.50149,0,0,0-2.78809,1.81836,8.0855,8.0855,0,0,0-1.751,2.89061,12.368,12.368,0,0,0,0,7.6836,8.0687,8.0687,0,0,0,1.751,2.89063A7.48955,7.48955,0,0,0,47.2851,119.563a10.37091,10.37091,0,0,0,3.72314.6289A8.69136,8.69136,0,0,0,55.7851,119.019a7.65872,7.65872,0,0,0,2.771-3.11035L54.748,113.73289a5.69171,5.69171,0,0,1-1.41064,1.76758,4.22674,4.22674,0,0,1-5.03222-.32324,3.85523,3.85523,0,0,1-.93506-2.73731v-2.85547A3.85523,3.85523,0,0,1,48.30518,106.84717Zm14.501,8.99316v3.94336H78.58154v-3.94336H73.21V94.62354H62.80615v3.94532h5.37207v17.27147Zm21.28321,0v3.94336H99.86572v-3.94336h-5.168V102.24072H84.08936v3.94336h5.57617v9.65625Z" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 2.7 KiB |
19
Cargo.toml
19
Cargo.toml
@ -20,13 +20,18 @@ debug-assertions = false
|
|||||||
path = "lib/lib.rs"
|
path = "lib/lib.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
cli-stylize = ["dep:bitflags"]
|
# cli utilities
|
||||||
logger = ["dep:log"]
|
"cli" = []
|
||||||
macros = []
|
"cli.stylize" = ["dep:bitflags"]
|
||||||
sched = ["dep:chrono"]
|
# logging
|
||||||
sched-tokio = ["dep:tokio", "tokio?/time", "tokio?/rt"]
|
"logger" = ["dep:log"]
|
||||||
sched-rule-recurrent = []
|
# macros
|
||||||
sched-rule-cron = []
|
"macros" = []
|
||||||
|
# scheduling
|
||||||
|
"sched" = ["dep:chrono"]
|
||||||
|
"sched.tokio" = ["dep:tokio", "tokio?/time", "tokio?/rt"]
|
||||||
|
"sched.rule-recurrence" = []
|
||||||
|
"sched.rule-cron" = []
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
12
README.md
12
README.md
@ -13,7 +13,15 @@
|
|||||||
|
|
||||||
# Features
|
# Features
|
||||||
|
|
||||||
- [x] [cli/stylize](lib/cli/stylize)
|
In order to avoid compiling unnecessary code and expensive dependencies, `lool` is split into
|
||||||
|
several features and "sub-features".
|
||||||
|
|
||||||
|
## Main features
|
||||||
|
|
||||||
|
- [x] [cli](lib/cli)
|
||||||
- [x] [logging](lib/logger)
|
- [x] [logging](lib/logger)
|
||||||
- [x] [macros](lib/macros)
|
- [x] [macros](lib/macros)
|
||||||
- [x] [tokio/sched](lib/tokio/sched)
|
- [x] [sched](lib/sched) <img src=".github/img/icon-has-submodules.svg" height="16">
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> <img src=".github/img/icon-has-submodules.svg" height="16"> : Means that the feature has sub-features.
|
||||||
24
lib/cli/README.md
Normal file
24
lib/cli/README.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<p align="center"><img src="./../../.github/img/logo-cli.svg" height="192"></p>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<p align="center"><b>lool » <code>cli</code></b> contains utilities for building command-line interfaces.</p>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
# Installation
|
||||||
|
|
||||||
|
This crate is for internal use. It's only published privately.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo add lool --registry=lugit --features cli
|
||||||
|
```
|
||||||
|
|
||||||
|
# Sub-Features
|
||||||
|
|
||||||
|
- [x] [`stylize`](./stylize): colorize and stylize text for the terminal.
|
||||||
@ -1,2 +1,2 @@
|
|||||||
#[cfg(feature = "cli-stylize")]
|
#[cfg(feature = "cli.stylize")]
|
||||||
pub mod stylize;
|
pub mod stylize;
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<p align="center"><b>lool » <code>cli/stylize</code></b> is a set of utilities for colorizing console outputs.
|
<p align="center"><b>lool » <code>cli.stylize</code></b> is a set of utilities for colorizing console outputs.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
@ -16,7 +16,7 @@
|
|||||||
This crate is for internal use. It's only published privately.
|
This crate is for internal use. It's only published privately.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cargo add lool --registry=lugit --features cli-stylize
|
cargo add lool --registry=lugit --features cli cli.stylize
|
||||||
```
|
```
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#[cfg(feature = "cli")]
|
||||||
pub mod cli;
|
pub mod cli;
|
||||||
|
|
||||||
#[cfg(feature = "sched")]
|
#[cfg(feature = "sched")]
|
||||||
|
|||||||
@ -23,20 +23,49 @@ cargo add lool --registry=lugit --features sched
|
|||||||
|
|
||||||
# Additional Features
|
# Additional Features
|
||||||
|
|
||||||
- `sched-tokio`: Enables the `tokio` runtime support.
|
- `sched.tokio`: Enables the `tokio` runtime support.
|
||||||
- `sched-rule-recurrent`: Enables the "recurrent-rule" style for scheduling tasks.
|
- `sched.rule-recurrent`: Enables the "recurrent-rule" style for scheduling tasks.
|
||||||
- `sched-rule-cron`: Enables the "cron-like" style for scheduling tasks
|
- `sched.rule-cron`: Enables the "cron-like" style for scheduling tasks
|
||||||
|
|
||||||
> [!WARNING] Not implemented warning
|
> [!WARNING] Not implemented warning
|
||||||
> although the `sched-rule-cron` feature is available, it's not yet implemented.
|
> although the `sched.rule-cron` feature is available, it's not yet implemented.
|
||||||
|
|
||||||
## Planned Features
|
## Planned Features
|
||||||
|
|
||||||
- `sched-rule-cron`: Enables the "cron-like" style for scheduling tasks
|
- `sched.rule-cron`: Enables the "cron-like" style for scheduling tasks
|
||||||
- `sched-rule-pysched`: Enables the "pysched-like" style for scheduling tasks
|
- `sched.rule-pyschedule`: Enables the [python schedule](https://pypi.org/project/schedule/)-like
|
||||||
|
style for scheduling tasks
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
TODO
|
TODO
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
|
||||||
|
# Inspiration
|
||||||
|
|
||||||
|
This library is inspired by several other libraries, including:
|
||||||
|
|
||||||
|
- [node-schedule](https://github.com/node-schedule/node-schedule?tab=readme-ov-file#recurrence-rule-scheduling):
|
||||||
|
where the idea of recurring rules was taken from.
|
||||||
|
- [tokio-schedule](https://github.com/dedefer/tokio_schedule): tokio async scheduler
|
||||||
|
- [schedule-rs](https://github.com/mehcode/schedule-rs): simple thread-based scheduler
|
||||||
|
- [croner-rust](https://github.com/hexagon/croner-rust): a croner parser for rust
|
||||||
|
- [job_scheduler](https://github.com/lholden/job_scheduler): another thread-based job scheduler for
|
||||||
|
rust
|
||||||
|
- [python's schedule](https://pypi.org/project/schedule/): a simple python scheduler with
|
||||||
|
a human-friendly API
|
||||||
|
|
||||||
|
|
||||||
|
Otros:
|
||||||
|
|
||||||
|
- https://crates.io/crates/tokio-cron-scheduler
|
||||||
|
- https://crates.io/crates/clokwerk
|
||||||
|
- https://crates.io/crates/cron_tab
|
||||||
|
- https://crates.io/crates/multithreading
|
||||||
|
- https://crates.io/crates/multithreading
|
||||||
|
- https://crates.io/crates/threadpool
|
||||||
|
- https://crates.io/crates/blocking
|
||||||
|
- https://crates.io/crates/scheduled-thread-pool
|
||||||
|
- https://crates.io/crates/clokwerk
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
#[cfg(feature = "sched-rule-cron")]
|
#[cfg(feature = "sched.rule-cron")]
|
||||||
mod cron;
|
mod cron;
|
||||||
#[cfg(feature = "sched-rule-recurrent")]
|
#[cfg(feature = "sched.rule-recurrence")]
|
||||||
mod recurrent;
|
mod recurrent;
|
||||||
#[cfg(feature = "sched-rule-recurrent")]
|
#[cfg(feature = "sched.rule-recurrence")]
|
||||||
pub use self::recurrent::{many, range, ranges, ruleset, val, RecurrenceRuleSet, Rule};
|
pub use self::recurrent::{many, range, ranges, ruleset, val, RecurrenceRuleSet, Rule};
|
||||||
|
|
||||||
use chrono::{DateTime, Local};
|
use chrono::{DateTime, Local};
|
||||||
@ -18,11 +18,11 @@ pub enum SchedulingRule {
|
|||||||
Once(chrono::DateTime<Local>),
|
Once(chrono::DateTime<Local>),
|
||||||
|
|
||||||
/// 🧉 » a scheduling rule expressed with a `RecurrenceRule` structure
|
/// 🧉 » a scheduling rule expressed with a `RecurrenceRule` structure
|
||||||
#[cfg(feature = "sched-rule-recurrent")]
|
#[cfg(feature = "sched.rule-recurrence")]
|
||||||
Repeat(RecurrenceRuleSet),
|
Repeat(RecurrenceRuleSet),
|
||||||
|
|
||||||
/// 🧉 » a scheduling rule expressed in cron format
|
/// 🧉 » a scheduling rule expressed in cron format
|
||||||
#[cfg(feature = "sched-rule-cron")]
|
#[cfg(feature = "sched.rule-cron")]
|
||||||
Cron(String),
|
Cron(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,17 +33,22 @@ impl SchedulingRule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 🧉 » get the next execution time from now
|
/// 🧉 » get the next execution time from now
|
||||||
pub fn next_from(&self, _date: DateTime<Local>) -> Option<DateTime<Local>> {
|
pub fn next_from(&self, date: DateTime<Local>) -> Option<DateTime<Local>> {
|
||||||
match self {
|
match self {
|
||||||
SchedulingRule::Once(_dt) => {
|
SchedulingRule::Once(date) => {
|
||||||
unimplemented!()
|
if date > &date {
|
||||||
|
Some(*date)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
}
|
}
|
||||||
#[cfg(feature = "sched-rule-recurrent")]
|
|
||||||
SchedulingRule::Repeat(_rule) => {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
}
|
||||||
#[cfg(feature = "sched-rule-cron")]
|
|
||||||
|
#[cfg(feature = "sched.rule-recurrence")]
|
||||||
|
SchedulingRule::Repeat(rule) => rule.next_match_from(date),
|
||||||
|
|
||||||
|
#[cfg(feature = "sched.rule-cron")]
|
||||||
SchedulingRule::Cron(_cron) => {
|
SchedulingRule::Cron(_cron) => {
|
||||||
|
// TODO: implement cron scheduling rule
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user