serge-test-parser

Serge

# `serge-test-parser`

# NAME

serge-test-parser - Test parser against any given file

# SYNOPSIS

`serge test-parser <parser_name> <file_path> [--import-mode] [--output-mode=<mode>] [--data-file=<file_path>]`

Where `<parser_name>` is a class name of the parser, and `<file_path>` is a path to the localizable file to test this parser on.

Note that you can omit the `Serge::Engine::Plugin::` prefix of the parser class name if your parser is located in lib/Serge/Engine/Plugin folder. Consider the following examples of `<parser_name>` parameter:

parse_android

  Use `Serge::Engine::Plugin::parse_android` parser class.

Serge::Engine::Plugin::parse_android

  Same as above (explicit class declaration).

ACME::Parser

  Use `ACME::Parser` parser class.

# DESCRIPTION

Parse the given file using the selected parser and emit the resulting data in one of the available formats. This is useful for writing new parsers.

# OPTIONS

--import-mode

  With this option, parser will be told it works in import mode. In such mode import-aware parsers are expected to extract translations rather than source strings, and also skip missing translations.

--output-mode=<mode>

  By default, parsed data will be emitted in an easily readable Config::Neat format (the format used in Serge configuration files). Such files are also suitable for diff. However, there are alternative output modes available:

  dumper

    Use Data::Dumper to dump the parsed structure. The format is a bit verbose, but can be handy for debugging.

--as-objects

  By default, parsed data is rendered as an array of arrays; each inner array holds fields in the following order: string, context, hint, flagsref, lang, key. With --as-objects, the data will be rendered as an array of objects with corresponding key names for better readability.

--data-file=<file_path>

  Some parsers require configuration data. You can pass data structure to the parser using this parameter. Target file should be a configuration file in Config::Neat format with the parser data that you would usually put into `jobs > ... > parser > data` section of Serge configuration file.

# SEE ALSO

Part of serge suite.