Console commands for the glassy framework
-
Add the dependency to your
shard.yml
:dependencies: glassy-console: github: glassy-framework/glassy-console
-
Run
shards install
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)
Always run crystal spec before submiting code
- 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
- Anderson Danilo - creator and maintainer