glassy-console
glassy-console
Console commands for the glassy framework
Installation
-
Add the dependency to your
shard.yml
:dependencies: glassy-console: github: glassy-framework/glassy-console
-
Run
shards install
Usage
We recommend using with the DI container, available in glassy-kernel.
Add the Console Bundle to your DI container:
require "glassy-kernel"
require "glassy-console"
require "./commands/my_command"
class AppKernel < Glassy::Kernel::Kernel
register_bundles [
Glassy::Console::Bundle,
MyAppBundle
]
end
Create your command:
require "glassy-console"
class MyCommand < Glassy::Console::Command
property name : String = "my:command"
property description : String = "my description"
@[Argument(name: "name", desc: "Name of the person")]
@[Option(name: "fill", desc: "Fill or not?")]
def execute(name : String, fill : Bool)
output.writeln("name = #{name}")
output.writeln("fill = #{fill}")
end
end
Add to your service file (services.yml)
services:
my_command:
class: MyCommand
kwargs:
input: '@console_input'
output: '@console_output'
tag:
- command
Now you can run setup your console application:
kernel = AppKernel.new
kernel.container.console_app.run(ARGV)
Development
Always run crystal spec before submiting code
Contributing
- Fork it (https://github.com/glassy-framework/glassy-console/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Anderson Danilo - creator and maintainer
Repository
glassy-console
Owner
Statistic
- 1
- 0
- 0
- 4
- 1
- about 4 years ago
- August 16, 2020
License
MIT License
Links
Synced at
Thu, 21 Nov 2024 13:33:45 GMT
Languages