https://github.com/luckyframework/lucky_task
Library for creating command line tasks for the Lucky CLI
https://github.com/luckyframework/lucky_task
crystal crystal-lang lucky-framework
Last synced: 11 months ago
JSON representation
Library for creating command line tasks for the Lucky CLI
- Host: GitHub
- URL: https://github.com/luckyframework/lucky_task
- Owner: luckyframework
- License: mit
- Created: 2021-04-04T02:55:05.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-09-22T17:36:29.000Z (over 2 years ago)
- Last Synced: 2024-05-06T00:04:54.178Z (almost 2 years ago)
- Topics: crystal, crystal-lang, lucky-framework
- Language: Crystal
- Homepage:
- Size: 87.9 KB
- Stars: 7
- Watchers: 4
- Forks: 5
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lucky Task
A Crystal library for creating command line tasks to be used with the [LuckyCli](https://github.com/luckyframework/lucky_cli).
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
lucky_task:
github: luckyframework/lucky_task
```
2. Run `shards install`
## Integrating With LuckyCli
Create a file `tasks.cr` at the root of your project
```crystal
require "lucky_task"
# Using `lucky` from the command line will do nothing if you forget this
LuckyTask::Runner.run
```
## Creating Tasks
Create a `tasks` directory in the root of your project.
Update your `tasks.cr` file to require all files within that directory for them to be registered with the CLI.
```crystal
# tasks.cr
require "lucky_task"
require "./tasks/*"
```
In the directory create a file called `send_daily_notifications.cr`.
```crystal
class SendDailyNotifications < LuckyTask::Task
summary "Send notifications to users"
# Name is inferred from class name ("send_daily_notifications")
# It can be overridden:
#
# task_name "app.send_daily_notifications"
def call
# Code that sends notifications to all your users...
end
end
```
## Contributing
1. Fork it ()
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 a new Pull Request
## Contributors
- [matthewmcgarvey](https://github.com/matthewmcgarvey) - creator and maintainer