https://github.com/ayrat555/cronenberg
Simple cron command entry parser
https://github.com/ayrat555/cronenberg
cron nom parser-combinators rust
Last synced: 3 months ago
JSON representation
Simple cron command entry parser
- Host: GitHub
- URL: https://github.com/ayrat555/cronenberg
- Owner: ayrat555
- License: mit
- Created: 2018-02-14T06:01:08.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-16T06:21:12.000Z (over 7 years ago)
- Last Synced: 2025-08-24T06:36:33.998Z (5 months ago)
- Topics: cron, nom, parser-combinators, rust
- Language: Rust
- Homepage:
- Size: 40 KB
- Stars: 11
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# cronenberg [](https://travis-ci.org/ayrat555/cronenberg)
## simple cron command entry parser
`cronenberg` provides two core components
* `TimeItem`: An enum that represents cron command time or date field
* `CronItem`: A struct that represents cron command entry, for example, `* * 5-7 1,2,5 8 sudo rm -rf /`
## Installation
`cronenberg` is available on [crates.io](https://crates.io/crates/cronenberg) and can be included in your Cargo enabled project like this:
```toml
[dependencies]
cronenberg = "0.3.0"
```
Then include it in your code like this:
```rust
extern crate cronenberg;
```
## Example
```rust
extern crate cronenberg;
use cronenberg::CronItem;
use cronenberg::TimeItem::*;
use std::str::FromStr;
use std::string::ToString;
let s = "* * 5-7 1,2,5 8 ls -la";
assert_eq!(
CronItem::from_str(s).unwrap(),
CronItem {
minute: AllValues,
hour: AllValues,
day_of_month: Interval((5, 7)),
month: MultipleValues(vec![1, 2, 5]),
day_of_week: SingleValue(8),
command: String::from("ls -la"),
}
);
let cron_item = CronItem {
minute: MultipleValues(vec![1, 10]),
hour: Interval((1, 4)),
day_of_month: Interval((1, 11)),
month: MultipleValues(vec![1, 2, 5]),
day_of_week: AllValues,
command: String::from("pwd"),
};
assert_eq!("1,10 1-4 1-11 1,2,5 * pwd", cron_item.to_string());
```
## Contributing
1. [Fork it!](http://github.com/ayrat555/cronenberg/fork)
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
## Author
Ayrat Badykov (@ayrat555)
## License
cronenberg is released under the MIT License.