<commit_before># Time-stamp: <2012-10-09 10:02:16 a10022>
#
# search command for searching through sketch list
# <NAME>, October 1st, 2012.
# <EMAIL>

use Term::ANSIColor qw(:constants);

use DesignCenter::Config;

%COMMANDS =
  (
   'search' =>
   [[
     'search [REGEX | all]',
     'Search sketch repository, use "all" to list everything.',
     '(.*)'
    ]]
  );

######################################################################

sub command_search {
  my $regex=shift;
  $regex = "." if ($regex eq 'all' or !$regex);
  my $err = Util::check_regex($regex);
  if ($err) {
    Util::error($err);
  } else {
    @res = DesignCenter::Config->_repository->search($regex);
    if (@res) {
      Util::output("The following sketches ".(($regex eq '.')?"are available:":"match your query:")."\n\n");
      foreach my $found (@res) {
        print GREEN, $found->name, RESET, " ".$found->location."\n";
      }
    }
    else {
      Util::error("No sketches match your query.\n");
    }
  }
}
<commit_msg>search command prints description if available<commit_after># Time-stamp: <2012-10-09 18:44:50 a10022>
#
# search command for searching through sketch list
# <NAME>, October 1st, 2012.
# <EMAIL>

use Term::ANSIColor qw(:constants);

use DesignCenter::Config;

%COMMANDS =
  (
   'search' =>
   [[
     'search [REGEX | all]',
     'Search sketch repository, use "all" to list everything.',
     '(.*)'
    ]]
  );

######################################################################

sub command_search {
  my $regex=shift;
  $regex = "." if ($regex eq 'all' or !$regex);
  my $err = Util::check_regex($regex);
  if ($err) {
    Util::error($err);
  } else {
    $res = DesignCenter::Config->_repository->search($regex);
    if (keys %$res) {
      Util::output("The following sketches ".(($regex eq '.')?"are available:":"match your query:")."\n\n");
      foreach my $found (sort keys %$res) {
        print GREEN, $res->{$found}->name, RESET, " ".(($res->{$found}->metadata||{})->{description} or $res->{$found}->location)."\n";
      }
    }
    else {
      Util::error("No sketches match your query.\n");
    }
  }
}

{'fraction_non_alphanumeric': 0.25199063231850116, 'fraction_numerical': 0.022482435597189696, 'mean_word_length': 3.4132231404958677, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5708208', 'n_tokens_mistral': 745, 'n_tokens_neox': 696, 'n_words': 172}