<commit_before>require 'nehm/tracks_view_command'

module Nehm

  class SearchCommand < TracksViewCommand

    def initialize
      super
    end

    def execute
      @query = @options[:args].join(' ')
      super
    end

    def arguments
      { 'QUERY' => 'Search query' }
    end

    def program_name
      'nehm search'
    end

    def summary
      'Search tracks, print them nicely and download selected tracks'
    end

    def usage
      "#{program_name} QUERY [OPTIONS]"
    end

    protected

    def get_tracks
      UI.term 'You must provide an argument' if @query.empty?

      @track_manager.search(@query, @limit, @offset)
    end

  end
end<commit_msg>Use dash-options in search command<commit_after>require 'nehm/tracks_view_command'

module Nehm

  class SearchCommand < TracksViewCommand

    def initialize
      super

      add_option(:"-t", '-t PATH',
                 'Download track(s) to PATH')

      add_option(:"-pl", '-pl PLAYLIST',
                 'Add track(s) to iTunes playlist with PLAYLIST name')

      add_option(:"-lim", '-lim NUMBER',
                 'Show NUMBER tracks on each page')

    end

    def execute
      # Convert dash-options to normal options
      options_to_convert = { :"-t"   => :to,
                            :"-pl"  => :pl,
                            :"-lim" => :limit }

      options_to_convert.each do |k,v|
        value = @options[k]
        @options.delete(k)
        @options[v] = value unless value.nil?
      end

      @query = @options[:args].join(' ')
      super
    end

    def arguments
      { 'QUERY' => 'Search query' }
    end

    def program_name
      'nehm search'
    end

    def summary
      'Search tracks, print them nicely and download selected tracks'
    end

    def usage
      "#{program_name} QUERY [OPTIONS]"
    end

    protected

    def get_tracks
      UI.term 'You must provide an argument' if @query.empty?

      @track_manager.search(@query, @limit)
    end

  end
end
{'fraction_non_alphanumeric': 0.09748743718592964, 'fraction_numerical': 0.0, 'mean_word_length': 1.993984962406015, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3086371', 'n_tokens_mistral': 629, 'n_tokens_neox': 583, 'n_words': 178}