glassy-console

Version, currently master branch1 version
  • master branchlatestOct 10, 2020

github.com/glassy-framework/glassy-console

Console of the Glassy Framework

1 stars
2 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  glassy-console:
    github: glassy-framework/glassy-console
    branch: master

master is a branch, not a release, so this tracks it rather than pinning a version.

Then run:

shards install

shard.yml

Crystal
0.35.1
License
MIT
Author
Anderson Danilo

Dependencies

Runtime Dependencies

  • glassy-kernel*github: glassy-framework/glassy-kernel, branch: master

README

glassy-console

CircleCI

Console commands for the glassy framework

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      glassy-console:
        github: glassy-framework/glassy-console
  2. 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

  1. Fork it (https://github.com/glassy-framework/glassy-console/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 a new Pull Request

Contributors