command_kit.rb icon indicating copy to clipboard operation
command_kit.rb copied to clipboard

Port to Crystal

Open postmodern opened this issue 4 years ago • 3 comments

Port command_kit to Crystal.

postmodern avatar May 11 '21 10:05 postmodern

The ModuleMethods vs ClassMethods code can be ported to Crystal as nested macros:

module Mixin1
  module ClassMethods
    def foo
      puts "foo"
    end
  end

  module ModuleMethods
    macro extended
      macro included
        \{% if @type.module? %}
          extend ModuleMethods
        \{% else %}
          extend ClassMethods
        \{% end %}
      end
    end
  end

  extend ModuleMethods
end

module Mixin2
  include Mixin1
end

module Mixin3
  include Mixin2
end

class Foo
  include Mixin3
end

Foo.foo
# => foo

postmodern avatar May 11 '21 10:05 postmodern

Since Crystal is compiled, we won't be able to port CommandKit::Commands::AutoLoad or CommandKit::Commands::AutoRequire.

postmodern avatar May 11 '21 10:05 postmodern

Crystal does not currently support an equivalent to IO.winsize. We may have to add it as an extension to LibC (ex: ioctl.cr and C equivalent)

postmodern avatar May 11 '21 10:05 postmodern