<commit_before>module Kontena::Cli::Containers
  class InspectCommand < Clamp::Command
    include Kontena::Cli::Common

    parameter "CONTAINER_ID", "Container id"

    def execute
      require_api_url
      token = require_token

      service_name = container_id.match(/(.+)-(\d+)/)[1]
      result = client(token).get("containers/#{current_grid}/#{service_name}/#{container_id}/inspect")
      puts JSON.pretty_generate(result)
    end
  end
end<commit_msg>fix error on 'container inspect' command when service name cannot be parsed<commit_after>module Kontena::Cli::Containers
  class InspectCommand < Clamp::Command
    include Kontena::Cli::Common

    parameter "CONTAINER_ID", "Container id"

    def execute
      require_api_url
      token = require_token

      match = container_id.match(/(.+)-(\d+)/)
      if match
        service_name = match[1]
        result = client(token).get("containers/#{current_grid}/#{service_name}/#{container_id}/inspect")
        puts JSON.pretty_generate(result)
      else
        abort("Cannot resolve container service")
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11727272727272728, 'fraction_numerical': 0.0018181818181818182, 'mean_word_length': 3.45748987854251, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '2395796', 'n_tokens_mistral': 335, 'n_tokens_neox': 329, 'n_words': 71}