Skip to content

Instantly share code, notes, and snippets.

@ch1ago
Last active November 5, 2024 02:01
Show Gist options
  • Save ch1ago/53c2cc786c51c73b6f6f78da4a3ada79 to your computer and use it in GitHub Desktop.
Save ch1ago/53c2cc786c51c73b6f6f78da4a3ada79 to your computer and use it in GitHub Desktop.
liza picoruby:deploy
# A bit of context (I'm still writing the website with guides)
#
# Running this command
# `liza g command picoruby setup deploy`
#
# Generates file
# `app/dev/commands/picoruby_command.rb`
#
# This is the pattern:
# `liza g command NAME action1 action2`
#
# So now these command and actions can be called by
# `liza picoruby`
# `liza picoruby:setup`
# `liza picoruby:deploy`
#
# Meaning it will look for constant <NAME>Command, which has a rack-friendly DSL.
# `PicorubyCommand.call(env)`
#
# The end-developer will be allowed to write their commands with a rails-friendly DSL:
#
class PicorubyCommand < DevSystem::SimpleCommand
section :filters
def before
super
@t = Time.now
log "simple_args #{ simple_args }"
log "simple_booleans #{ simple_booleans }"
log "simple_strings #{ simple_strings }"
end
def after
super
log "#{ @t.diff }s | done"
end
section :actions
# liza picoruby s1 s2 s3 +b1 +b2 -b3 -b4 k1=v1 k2=v2
def call_default
log stick :b, :lightest_cobalt, "I just think Ruby is the Best for coding!"
end
# liza picoruby:setup
def call_setup
log stick :b, :light_umber, "I just think Ruby is the Best for coding!"
end
# liza picoruby:deploy
def call_deploy
log stick :b, :lightest_ruby, "I just think Ruby is the Best for coding!"
end
end
class PicorubyCommand < DevSystem::SimpleCommand
section :filters
def before
super
@t = Time.now
log "simple_args #{ simple_args }"
log "simple_booleans #{ simple_booleans }"
log "simple_strings #{ simple_strings }"
end
def after
super
log "#{ @t.diff }s | done"
end
section :actions
# liza picoruby s1 s2 s3 +b1 +b2 -b3 -b4 k1=v1 k2=v2
def call_default
log stick :b, :lightest_cobalt, "I just think Ruby is the Best for coding!"
end
# liza picoruby:setup
def call_setup
log stick :b, :light_umber, "I just think Ruby is the Best for coding!"
# complicated code here
log "Logs allow you to see the flow of your code"
# complicated code here
something_unexpected = true
return if something_unexpected
log "IT WORKS! OMG IT WORKS!"
end
# liza picoruby:deploy
def call_deploy
log stick :b, :lightest_ruby, "I just think Ruby is the Best for coding!"
sh "cp a b" if Shell.unix?
sh "cp a b" if Shell.windows?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment