Sha256: 0807f9d0dcc1042ed299aa9657f880280c925b989c841197f2d69c674818f1a3

Contents?: true

Size: 773 Bytes

Versions: 2

Compression:

Stored size: 773 Bytes

Contents

# frozen_string_literal: true

module Dry
  class CLI
    def exit(code); end

    def perform_registry(arguments)
      result = registry.get(arguments)
      return usage(result) unless result.found?

      command, args = parse(result.command, result.arguments, result.names)

      result.before_callbacks.run(command, args)
      output = command.call(**args)
      result.after_callbacks.run(command, args)

      output
    end
  end
end

module Pcli
  module Services
    class Commander
      include Depends.on('output', commands: 'all_commands')

      def initialize(**args)
        super

        @cli = Dry::CLI.new(commands.registry)
      end

      def run(cmd)
        @cli.call(arguments: cmd.split, out: output, err: output)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pcli-0.1.1 lib/pcli/services/commander.rb
pcli-0.1.0 lib/pcli/services/commander.rb