{"id":16100649,"url":"https://github.com/0x61nas/todo2","last_synced_at":"2026-03-27T04:52:45.292Z","repository":{"id":196173864,"uuid":"694964050","full_name":"0x61nas/todo2","owner":"0x61nas","description":"todo2(a.k.a. todo or die) - A better todo! macro inspired from searls/todo_or_die","archived":false,"fork":false,"pushed_at":"2024-05-20T05:35:01.000Z","size":169,"stargazers_count":11,"open_issues_count":3,"forks_count":3,"subscribers_count":0,"default_branch":"aurora","last_synced_at":"2024-05-20T21:12:38.065Z","etag":null,"topics":["hacktoberfest","hacktoberfest-accepted","proc-macro","rust","rust-crate","todo"],"latest_commit_sha":null,"homepage":"https://lib.rs/crates/todo2","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0x61nas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://www.buymeacoffee.com/0x61nas"]}},"created_at":"2023-09-22T04:07:53.000Z","updated_at":"2024-06-03T06:37:08.859Z","dependencies_parsed_at":"2024-01-08T06:54:28.943Z","dependency_job_id":"15f79dbd-8dca-4f70-bf09-4a0122a72b37","html_url":"https://github.com/0x61nas/todo2","commit_stats":null,"previous_names":["0x61nas/todo2"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x61nas%2Ftodo2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x61nas%2Ftodo2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x61nas%2Ftodo2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x61nas%2Ftodo2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0x61nas","download_url":"https://codeload.github.com/0x61nas/todo2/tar.gz/refs/heads/aurora","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243806070,"owners_count":20350775,"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":["hacktoberfest","hacktoberfest-accepted","proc-macro","rust","rust-crate","todo"],"created_at":"2024-10-09T18:47:35.847Z","updated_at":"2026-03-27T04:52:45.238Z","avatar_url":"https://github.com/0x61nas.png","language":"Rust","funding_links":["https://www.buymeacoffee.com/0x61nas"],"categories":[],"sub_categories":[],"readme":"# todo2\n\ntodo2(a.k.a. todo or die) - A better `todo!` macro inspired from [searls/todo_or_die](https://github.com/searls/todo_or_die)\n\n[![crates.io](https://img.shields.io/crates/v/todo2.svg)](https://crates.io/crates/todo2)\n[![docs.rs](https://docs.rs/todo2/badge.svg)](https://docs.rs/todo2)\n[![downloads](https://img.shields.io/crates/d/todo2.svg)](https://crates.io/crates/todo2)\n[![license](https://img.shields.io/crates/l/todo2.svg)](https://github.com/0x61nas/todo2/blob/aurora/LICENSE)\n\nThis crate provides a better `todo!` macro, which allows you to specify the deadline and the condition when the code should be implemented.\nand when the condition or the deadline is met, the code will panic or emit a compile error, or just log an error.\n\n\u003e Note: this crate is still in the early development, so it may have some bugs, and the API may change in the future.\n\u003e If you have any suggestions or you found a bug, please open an issue or a pull request.\n\n## Usage\nAdd this to your `Cargo.toml`:\n```toml\n[dependencies]\ntodo2 = \"0.1.0\"\n```\nor just run this command:\n```sh\ncargo add todo2\n```\n\n```rust\n#[macro_use]\nextern crate todo2;\n\nfn main() {\n  todo!(\"Hack NASA\", by: 2024-3-26 at 9:00);\n  get_a_hot_gf(true)\n}\n\nfn get_a_hot_gf(single: bool) {\n todo!(\"Get a hot girlfriend\", if: single);\n}\n```\n\n## Features\n- `log` - Just logs an error instead of panicking or emitting a compile error, this may useful in the serious projects, this feature respects that you have added the `log` crate to your dependencies\n- `compile-error` - Emits a compile error instead of panicking.\n- `with-chrono` - Enables the `chrono` this enables you to specify the deadline for the `by` condition using the [`chrono::Utc`](https://docs.rs/chrono/latest/chrono/struct.Utc.html) or [`chrono::DateTime`](https://docs.rs/chrono/latest/chrono/struct.DateTime.html) types. [not implemented yet](#maybe)\n- `with-time` - Enables the `time` this enables you to specify the deadline for the `by` condition using the [`time::OffsetDateTime`](https://docs.rs/time/latest/time/struct.OffsetDateTime.html) type or the [`time::macros::datetime`](https://docs.rs/time/0.3.28/time/macros/macro.datetime.html) macro. [not implemented yet](#maybe)\n- `and-time` - allows you to specify a specific time of the day in the `by` condition\n- `original-compatibility` - Allows you to use this macro without pass any arguments, or with only the message.\n- `strict-syntax` - Enables the strict syntax,, just too force you to put a comma or a semicolon after the message.\n- `chrono-backend` - Use the `chrono` as the backend instead of the default implementation for the `by` condition to calculate the unix time stamp. I prefer to enable this feature if I have chrono in the dependencies, because it's more accurate than the default implementation. [Read more](#backends)\n- `time-backend` - Use the `time` as the backend instead of the default implementation for the `by` condition to calculate the unix time stamp. I prefer to enable this feature if I have time in the dependencies, because it's more accurate than the default implementation. [Read more](#backends)\n- `am-cool` - To indicate that you are cool. I love you.\n\nThe default features are: `original-compatibility`, `strict-syntax`, `and-time`, `time-backend`.\n\n## Examples\n### Using the `log` feature\nYou have to enable the `log` feature in your `Cargo.toml`:\n```toml\n[dependencies]\n# You also have to add the `log` crate to your dependencies\nlog = \"0.4.20\"\n# Use any implementation you want for the logging, in this example, I will use the `simple_logger` crate\nsimple_logger = \"4.2.0\"\n# and of course, our beloved `todo2` crate\ntodo2 = { version = \"0.1.0\", features = [\"log\"] }\n```\n```rust\n#[macro_use]\nextern crate todo2;\n#[macro_use]\nextern crate log;\n\nuse simple_logger::SimpleLogger;\n\nfn main() {\n    // Initialize the logger\n    SimpleLogger::new().init().unwrap();\n\n    todo!(\"Make a cool crate\", by: 2024-02-02)\n}\n```\nThis will log an error like this when the deadline is met:\n```log\n2024-02-02T17:27:07.013874956Z ERROR [logging_example] src/main.rs:9: Make a cool crate\n```\nconsider that you can't enable the `compile-error` feature with the `log` feature. only one of them can be enabled at a time.\n\n### Using the `compile-error` feature\nFirst, add the crate to your `Cargo.toml` and enable the `compile-error` feature:\n```sh\ncargo add todo2 --features compile-error\n```\n```rust\n#[macro_use]\nextern crate todo2;\n\nfn main() {\n   todo!(\"Remove this secret\", by: 2024-02-23);\n   let my_little_secret = \"very secret\";\n}\n```\nthis will emit a compile error like this, when u try to compile the code in release mode.\n\n## Time in the `by` condition\nby default, the `by` condition takes a raw date and parse it with our custom parser, which expects the date in the `YYYY-MM-DD` format and `YYYY-MM-DD at HH:MM` or `YYYY-MM-DD @ HH:MM` format if you have the `and-time` feature enabled.\nand then it calculates the unix time stamp in UTC, and then compares it with the current time stamp.\n\nthis for the parsing part, noting interested here. just macros magic. the complexity comes when we want to calculate the unix time stamp from the parsed date.\nhere the time zones and the daylight saving time and the leap seconds come to play.\nand I don't want to deal with this complexity 'cause I'm lazy and this is a \"proc macro\" not a normal crate witch means that it runs at compile time, and we all know that the rust compile times is so \"fast\" :) and I don't want to make it slower.\nso I implemented a simple algorithm to calculate the unix time stamp, which is not accurate, but it works. hmm, kinda.\n\n### Backends\nand that's why we have the `chrono-backend` and the `time-backend` features, to use the `chrono` or the `time` crate to calculate the unix time stamp instead of the default implementation.\n\nI encourage you to enable one of them if you don't have a problem with adding yet another dependence to your project dependencies tree, or if you already have one of them in your dependencies already.\nat least until we have a better implementation for the default backend.\n\nthe backend doesn't affect the parsing part, or the syntax, it only affects the calculation of the unix time stamp, witch is internal thing, so you don't have to worry about it from this perspective.\n\n## Maybe?\nHere some ideas that I may implement in the future releases:\n- [ ] Implement the `with-chrono` feature, to enable the user to use the [`chrono::Utc`](https://docs.rs/chrono/latest/chrono/struct.Utc.html) or [`chrono::DateTime`](https://docs.rs/chrono/latest/chrono/struct.DateTime.html) types\nto specify the deadline for the `by` condition instead of the raw date.\nexample:\n```rust\ntodo!(\"Make a cool crate\", by: chrono::Utc.with_ymd_and_hms(2024, 02, 02, 9, 0, 0));\n```\n- [ ] Implement the `with-time` feature, to enable the user to use the [`time::OffsetDateTime`](https://docs.rs/time/latest/time/struct.OffsetDateTime.html) type or the [`time::macros::datetime`](https://docs.rs/time/0.3.28/time/macros/macro.datetime.html) macro to specify the deadline for the `by` condition instead of the raw date.\nexample:\n```rust\ntodo!(\"Make a cool crate\", by: time::macros::datetime!(2024-02-02 09:00:00));\n```\n- [ ] Make the `if` condition parser able to evaluate some conditions at compile time, so we can use the `compile-error` feature with the `if` condition.\nexample:\n```rust\n   todo!(\"Remove this secret\", if: !cfg!(debug_assertions));\n   let my_little_secret = \"i love you\";\n```\n\n## Contributing\nI'm happy to accept any contributions, just consider reading the [CONTRIBUTING.md](https://github.com/0x61nas/todo2/blob/aurora/CONTRIBUTING.md) guide first. to avoid waste waste our time on some unnecessary things.\n\n\u003e the main keywords are: **signed commits**, **conventional commits**, **no emojis**, **the PR shouldn't have more then tree commits most of the time**\n\n## License\nThis project is licensed under the MIT license. [Read more](https://github.com/0x61nas/todo2/blob/aurora/LICENSE)\nAnd you can use it under the Unlicense license if you want. [Read more](https://github.com/0x61nas/todo2/blob/aurora/LICENSE-UNLICENSE)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0x61nas%2Ftodo2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0x61nas%2Ftodo2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0x61nas%2Ftodo2/lists"}