#!/usr/bin/ruby

require 'thor'
require 'jenkins2-api'

module Jenkins2API
  # CLI wrapper under Jenkins2API
  module CLI
    # Base class for Thor with registered modules and version info
    class Jenkins2 < Thor
      map %w[--version -v] => :__print_version

      desc '--version, -v', 'print the version'
      # Prints the current version number
      def __print_version
        puts Jenkins2API::VERSION
      end

      register(
        Jenkins2API::Command::Job,
        'job',
        'job <command>',
        'Job related commands'
      )
      register(
        Jenkins2API::Command::Build,
        'build',
        'build <command>',
        'Build related commands'
      )
      register(
        Jenkins2API::Command::Node,
        'node',
        'node <command>',
        'Node related commands'
      )
      register(
        Jenkins2API::Command::Plugin,
        'plugin',
        'plugin <command>',
        'Plugins related commands'
      )
      register(
        Jenkins2API::Command::System,
        'system',
        'system <command>',
        'System related commands'
      )
    end
  end
end

Jenkins2API::CLI::Jenkins2.start
