Skip to content

Instantly share code, notes, and snippets.

@lukassup
Created July 21, 2021 14:09
Show Gist options
  • Save lukassup/3914b605ea1f77bae0a00a9af127227e to your computer and use it in GitHub Desktop.
Save lukassup/3914b605ea1f77bae0a00a9af127227e to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# vim: set ft=ruby:
# frozen_string_literal: true
require "bundler/setup"
require "dry/cli"
module ZX
module CLI
class SudoCommand < Dry::CLI::Command
option :sudo, type: :boolean, desc: 'Use sudo?'
end
module Commands
extend Dry::CLI::Registry
class Exec < SudoCommand
desc "Execute a task"
argument :task, type: :string, required: true, desc: "Task to be executed"
argument :dirs, type: :array, required: false, desc: "Optional directories"
def call(task:, dirs: [], **)
puts "exec - task: #{task}, dirs: #{dirs.inspect}"
end
end
register "exec", Exec
end
end
end
Dry::CLI.new(ZX::CLI::Commands).call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment