# encoding: utf-8 module GithubCLI class Commands::Labels < Command namespace :label desc 'list ', 'Listing all labels for this repository.' option :milestone, :type => :string, :aliases => ["-m"], :banner => '', :desc => 'List labels for every issue in a milestone.' option :issue, :type => :string, :aliases => ["-i"], :banner => '', :desc => 'List labels on an issue.' def list(user, repo) global_options = options.dup params = options[:params].dup params_remove = params.keys + ['params'] if (milestone_id = options[:milestone]) params['milestone_id'] = milestone_id params_remove << 'milestone' elsif (issue_id = options[:issue]) params['issue_id'] = issue_id params_remove << 'issue' end Util.hash_without!(global_options, params_remove) Label.all user, repo, params, global_options end desc 'get ', 'Get a single label.' def get(user, repo, name) global_options = options.dup params = options[:params].dup Util.hash_without!(global_options, params.keys + ['params']) Label.get user, repo, name, params, global_options end option :name, :type => :string, :required => true option :color, :type => :string, :required => true desc 'create ', 'Create a label.' long_desc <<-DESC Inputs name - Required string color - Required string - 6 character hex code, without leading # DESC def create(user, repo) global_options = options.dup params = options[:params].dup params['name'] = options[:name] if options[:name] params['color'] = options[:color] if options[:color] Util.hash_without!(global_options, params.keys + ['params']) Label.create user, repo, params, global_options end option :name, :type => :string, :required => true option :color, :type => :string, :required => true desc 'update ', 'Update a label.' long_desc <<-DESC Inputs name - Required string color - Required string - 6 character hex code, without leading # DESC def update(user, repo, name) global_options = options.dup params = options[:params].dup params['name'] = options[:name] if options[:name] params['color'] = options[:color] if options[:color] Util.hash_without!(global_options, params.keys + ['params']) Label.update user, repo, name, params, global_options end desc 'delete ', 'Delete a label.' def delete(user, repo, name) global_options = options.dup params = options[:params].dup Util.hash_without!(global_options, params.keys + ['params']) Label.delete user, repo, name, params, global_options end desc 'add