<commit_before># encoding: utf-8

gem 'thor'
require 'thor'

class Eye::Cli < Thor
  autoload :Server,     'eye/cli/server'
  autoload :Commands,   'eye/cli/commands'
  autoload :Render,     'eye/cli/render'

  include Eye::Cli::Server
  include Eye::Cli::Commands
  include Eye::Cli::Render

  desc "info [MASK]", "processes info"
  def info(mask = nil)
    res = cmd(:info_data, *Array(mask))
    if mask && res[:subtree] && res[:subtree].empty?
      error!("command :info, objects not found!")
    end
    say render_info(res)
    say
  end

  desc "status NAME", "return exit status for process name 0-up, 3-unmonitored"
  def status(name)
    res = cmd(:info_data, *Array(name))
    es, msg = render_status(res)
    say(msg, :red) if msg && !msg.empty?
    exit(es)
  end
<commit_msg>add json output for eye info<commit_after># encoding: utf-8

gem 'thor'
require 'thor'

class Eye::Cli < Thor
  autoload :Server,     'eye/cli/server'
  autoload :Commands,   'eye/cli/commands'
  autoload :Render,     'eye/cli/render'

  include Eye::Cli::Server
  include Eye::Cli::Commands
  include Eye::Cli::Render

  desc "info [MASK]", "processes info"
  method_option :json, :type => :boolean, :aliases => "-j"
  def info(mask = nil)
    res = cmd(:info_data, *Array(mask))
    if mask && res[:subtree] && res[:subtree].empty?
      error!("command :info, objects not found!")
    end

    if options[:json]
      require 'json'
      say JSON.dump(res)
    else
      say render_info(res)
      say
    end
  end

  desc "status NAME", "return exit status for process name 0-up, 3-unmonitored"
  def status(name)
    res = cmd(:info_data, *Array(name))
    es, msg = render_status(res)
    say(msg, :red) if msg && !msg.empty?
    exit(es)
  end

{'fraction_non_alphanumeric': 0.14506880733944955, 'fraction_numerical': 0.0034403669724770644, 'mean_word_length': 3.2874692874692877, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5124515', 'n_tokens_mistral': 640, 'n_tokens_neox': 612, 'n_words': 171}