alias DeviceName = String alias DeviceFile = Int32 alias DeviceDir = Hash(DeviceName, DeviceFile | DeviceDir) pp Hash(DeviceName, DeviceDir).new pp Hash(DeviceName, DeviceFile).new pp DeviceDir.new #=> 21 | pp DeviceDir.new #=> ^-- #=> Error: undefined method 'new' for DeviceDir.class
DeviceDiris an alias of
Hash(DeviceName, DeviceFile | DeviceDir), why can't I call
Optionsarray can hold, but
addmethod isn't imposing any restriction, so it might break for cases where you call
addwith type which isn't part of your expected types.
this snippet contains a macro check for
add method and ensure only allowed types are allowed at compile time. So if you try invoking
add method with Types which aren't part of
Type alias, it will fail to compile.
also in your class you have restricted the types which Options array can hold, but add method isn't imposing any restriction, so it might break for cases where you call add with type which isn't part of your expected types.
Good call, I'd actually be fine without such restriction; just an array of OptionBuilder(T). I'd like to use the type to cast string values to (T), but probably not the best idea: https://play.crystal-lang.org/#/r/e7uu
looking for something in particular?
Was looking for something lightweight, extensible and up to date with latest Crystal.
I was looking into Admiral and Commander, but I think I'm going to poke around the docs for Athena console.
I want to attach a CLI to a task runner (base/abstract class), but also be able to compose (sub)commands in implementations of the task runner.
:as a way to group related commands. E.g.
@Blacksmoke16 athena console ended up being pretty slick. Thanks.
Now I just need to dig myself out of the hole I made by using
with ... yield. :) Hoping this one moves forward.