<commit_before>#include <iomanip>
#include <boost/regex.hpp>
#include <qi/iocolor.hpp>
#include "sessionhelper.hpp"

SessionHelper::SessionHelper(const std::string &address)
{
  _session.connect(address);
  _session.disconnected.connect(boost::bind(&SessionHelper::onDisconnect, this, _1));
}

SessionHelper::~SessionHelper()
{
  _session.close();
}

ServiceHelper SessionHelper::getService(const std::string &serviceName)
{
  qi::FutureSync<qi::ObjectPtr> future = _session.service(serviceName);

  if (future.hasError())
    throw std::runtime_error(future.error());
  return ServiceHelper(future.value(), serviceName);
}

std::vector<ServiceHelper> SessionHelper::getServices(const std::string &pattern)
{
  std::vector<qi::ServiceInfo> servsInfos = _session.services().value();
  std::vector<ServiceHelper> services;
  services.reserve(servsInfos.size());
  boost::basic_regex<char> reg(pattern);

  for (unsigned int i = 0; i < servsInfos.size(); ++i)
  {
    if (boost::regex_match(servsInfos[i].name(), reg))
      services.push_back(getService(servsInfos[i].name()));
  }
  return services;
}

void SessionHelper::showServiceInfo(const qi::ServiceInfo &infos, bool verbose, bool showHidden, bool showDoc)
{
  std::cout << qi::StreamColor_Fuchsia
            << std::right << std::setw(3) << std::setfill('0')
            << infos.serviceId() << qi::StreamColor_Reset
            << std::left << std::setw(0) << std::setfill(' ')
            << " [" << qi::StreamColor_Red << infos.name() << qi::StreamColor_Reset << "]" << std::endl;

  if (!verbose)
    return;
<commit_msg>qicli: service: filter the service name with --show-hidden too<commit_after>#include <iomanip>
#include <boost/regex.hpp>
#include <qi/iocolor.hpp>
#include "sessionhelper.hpp"

SessionHelper::SessionHelper(const std::string &address)
{
  _session.connect(address);
  _session.disconnected.connect(boost::bind(&SessionHelper::onDisconnect, this, _1));
}

SessionHelper::~SessionHelper()
{
  _session.close();
}

ServiceHelper SessionHelper::getService(const std::string &serviceName)
{
  qi::FutureSync<qi::ObjectPtr> future = _session.service(serviceName);

  if (future.hasError())
    throw std::runtime_error(future.error());
  return ServiceHelper(future.value(), serviceName);
}

std::vector<ServiceHelper> SessionHelper::getServices(const std::string &pattern)
{
  std::vector<qi::ServiceInfo> servsInfos = _session.services().value();
  std::vector<ServiceHelper> services;
  services.reserve(servsInfos.size());
  boost::basic_regex<char> reg(pattern);

  for (unsigned int i = 0; i < servsInfos.size(); ++i)
  {
    if (boost::regex_match(servsInfos[i].name(), reg))
      services.push_back(getService(servsInfos[i].name()));
  }
  return services;
}

void SessionHelper::showServiceInfo(const qi::ServiceInfo &infos, bool verbose, bool showHidden, bool showDoc)
{
  if (!showHidden &&
      infos.name().size() > 0 && infos.name()[0] == '_')
    return;
  std::cout << qi::StreamColor_Fuchsia
            << std::right << std::setw(3) << std::setfill('0')
            << infos.serviceId() << qi::StreamColor_Reset
            << std::left << std::setw(0) << std::setfill(' ')
            << " [" << qi::StreamColor_Red << infos.name() << qi::StreamColor_Reset << "]" << std::endl;

  if (!verbose)
    return;

{'fraction_non_alphanumeric': 0.17518910741301058, 'fraction_numerical': 0.003630862329803328, 'mean_word_length': 5.214285714285714, 'pattern_counts': {'":': 0, '<': 81, '<?xml version=': 0, '>': 20, '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': '5600528', 'n_tokens_mistral': 1100, 'n_tokens_neox': 1078, 'n_words': 182}