diff --git a/CHANGELOG b/CHANGELOG index 736a51b2..88bd8368 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,7 +9,10 @@ jc changelog - Enhance `proc-net-tcp` parser to add opposite endian support for architectures like the s390x - Enhance `url` parser to add `parent`, `filename`, `stem`, and `extension` fields +- Enhance `/proc` file magic syntax to allow slurping when multiple files are selected + and to include the `_file` metadata field in the data - Fix `ini` and `ini-dup` parsers to consistently handle null values as empty strings +- Fix line slicer to not skip blank lines - Add source link to online parser documentation - Add snap package build scripts - Refactor parser aliases for `kv`, `pkg_index_deb`, `lsb_release`, and `os-release` diff --git a/jc/cli.py b/jc/cli.py index b1a40960..8e0b2f73 100644 --- a/jc/cli.py +++ b/jc/cli.py @@ -21,7 +21,7 @@ from .jc_types import JSONDictType, CustomColorType, ParserInfoType from . import utils from .cli_data import ( long_options_map, new_pygments_colors, old_pygments_colors, helptext_preamble_string, - helptext_end_string + slicetext_string, helptext_end_string ) from .shell_completions import bash_completion, zsh_completion from . import tracebackplus @@ -289,7 +289,7 @@ class JcCli(): """Return the help text with the list of parsers""" parsers_string: str = self.parsers_text() options_string: str = self.options_text() - helptext_string: str = f'{helptext_preamble_string}{parsers_string}\nOptions:\n{options_string}\n{helptext_end_string}' + helptext_string: str = f'{helptext_preamble_string}{parsers_string}\nOptions:\n{options_string}\n{slicetext_string}\n{helptext_end_string}' return helptext_string def help_doc(self) -> None: diff --git a/jc/cli_data.py b/jc/cli_data.py index 2cc4a19b..07cc91bc 100644 --- a/jc/cli_data.py +++ b/jc/cli_data.py @@ -79,6 +79,17 @@ Usage: Parsers: ''' +slicetext_string: str = '''\ +Slice: + [start]:[end] + + start: [[-]index] - Zero-based start line, negative index for + counting from the end + + end: [[-]index] - Zero-based end line (excluding the index), + negative index for counting from the end +''' + helptext_end_string: str = '''\ Examples: Standard Syntax: @@ -90,7 +101,8 @@ Examples: $ jc --pretty /proc/meminfo Line Slicing: - $ cat file.csv | jc :101 --csv # parse first 100 lines + $ $ cat output.txt | jc 4:15 --parser # Parse from line 4 to 14 + with parser (zero-based) Parser Documentation: $ jc --help --dig