Sha256: 38e9dd4339f345f217b118377a8bbb2d329bf7725da73fb02ae1f8d81a199a45

Contents?: true

Size: 1.97 KB

Versions: 1

Compression:

Stored size: 1.97 KB

Contents

module Comply
  module CLI
    module Subcommands
      module Integrations
        include Helpers::Integration

        def self.included(thor)
          thor.class_eval do
            desc 'integrations:list', 'List integrations'
            define_method 'integrations:list' do
              integrations = default_program.integrations
              if integrations.empty?
                say 'No integrations found.'
              else
                integrations.each do |integration|
                  say pretty_print_integration(integration)
                end
              end
            end

            desc 'integrations:enable INTEGRATION_ID', 'Enable an integration'
            define_method 'integrations:enable' do |integration_type|
              integration = default_program.integrations.find do |i|
                i.integration_type == integration_type
              end
              raise Thor::Error, 'Integration already enabled' if integration

              prompt_and_create_integration(integration_type)
            end

            desc 'integrations:update INTEGRATION_ID', 'Enable an integration'
            define_method 'integrations:update' do |integration_type|
              integration = default_program.integrations.find do |i|
                i.integration_type == integration_type
              end
              raise Thor::Error, 'Integration not found' unless integration

              prompt_and_update_integration(integration)
            end

            desc 'integrations:sync INTEGRATION_ID', 'Sync an integration'
            define_method 'integrations:sync' do |integration_type|
              integration = default_program.integrations.find do |i|
                i.integration_type == integration_type
              end
              raise Thor::Error, 'Integration not found' unless integration

              integration.links['sync'].post
              say 'Integration synced'
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
comply-cli-0.0.1 lib/comply/cli/subcommands/integrations.rb