diff --git a/Cargo.lock b/Cargo.lock index 7aefb1e..05b4c20 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -748,7 +748,7 @@ dependencies = [ [[package]] name = "json-lines-viewer" -version = "0.4.3" +version = "0.4.4" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index 63e95ee..f9a2a25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,11 @@ [package] name = "json-lines-viewer" -version = "0.4.3" +version = "0.4.4" edition = "2024" -description = "JSON Lines Viewer - Terminal-UI to view application logs in 'Json line format' or Zip files containing such files" +description = "JSON Lines Viewer - Terminal-UI to view JSON line files (e.g. application logs) or Zip files containing such files" +documentation = "https://github.com/bitmagier/json-lines-viewer" authors = ["Roman Krüger"] -keywords = ["Json", "viewer", "TUI"] +keywords = ["JSON", "viewer", "TUI"] license = "MIT" repository = "https://github.com/bitmagier/json-lines-viewer" diff --git a/README.md b/README.md index 52461ea..8d7e95c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ JSON Lines Viewer --- -A terminal-UI to browse through JSON-line files. +Terminal-UI to view JSON line files (e.g. application logs) or Zip files containing such files _The main use case is to support the analysis of comprehensive application logs in 'Json line' format._ @@ -17,11 +17,11 @@ Download precompiled binary for your platform from Github. ## Usage ``` -JSON Lines Viewer - Terminal-UI to view application logs in 'Json line format' or Zip files containing such files. +JSON Lines Viewer - Terminal-UI to view '.json' line files (e.g. application logs) or Zip files containing such files Navigation: Cursor keys, PageUp/Down, Enter/Esc. -Find content: Ctrl-f or '/' and navigate to next/previous finding via cursor Down/Up. -Save current settings: Ctrl-s (e.g. field order. Settings come from commandline arguments and a previously saved config file) +Search content: Ctrl-f or '/' and navigate to next/previous finding via cursor down/up. Leave search field with `Esc`. +Save current settings: Ctrl-s (Settings may come from commandline options and a previously saved config file) Usage: json-lines-viewer [OPTIONS] [FILES]... @@ -38,14 +38,16 @@ Options: -h, --help Print help (see a summary with '-h') + + -V, --version + Print version ``` ### Example ``` -json-lines-viewer --field-order @timestamp,level,application_id,message,application_version,land,host_ipv4,host_name,thread_name,correlation_id,logger_name logs-export-XXXX.zip +json-lines-viewer --field-order @timestamp,level,application_id,message,application_version,land,host_ipv4,host_name,thread_name,correlation_id,logger_name logs-export-xxxxx.zip ``` - ## Program navigation / usage - Use Cursor Keys and PageUp/PageDown to navigate on a page diff --git a/src/main.rs b/src/main.rs index 8c845dc..bb64041 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,11 +18,11 @@ use std::io::BufRead; use std::path::{Path, PathBuf}; #[derive(Parser, Debug)] -#[command(version, about, long_about = Some("JSON Lines Viewer - Terminal-UI to view application logs in 'Json line format' or Zip files containing such files.\n\ - \n\ - Navigation: Cursor keys, PageUp/Down, Enter/Esc.\n\ - Search content: Ctrl-f or '/' and navigate to next/previous finding via cursor Down/Up.\n\ - Save current settings: Ctrl-s (e.g. field order. Settings come from commandline arguments and a previously saved config file)"))] +#[command(version, about, long_about = Some("JSON Lines Viewer - Terminal-UI to view JSON line files (e.g. application logs) or Zip files containing such files\n\ + \n\ + Navigation: Cursor keys, PageUp/Down, Enter/Esc.\n\ + Search content: Ctrl-f or '/' and navigate to next/previous finding via cursor down/up. Leave search field with `Esc`.\n\ + Save current settings: Ctrl-s (Settings may come from commandline options and a previously saved config file)"))] struct Args { /// JSON line input files - `.json` or `.zip` files(s) containing `.json` files files: Vec, @@ -98,7 +98,11 @@ fn load_files(files: &[PathBuf]) -> anyhow::Result { let mut raw_lines = RawJsonLines::default(); for path in files { - match path.extension().and_then(|e| e.to_str()) { + match path.extension() + .and_then(|e| e.to_str()) + .map(|e| e.to_ascii_lowercase()) + .as_deref() + { Some("json") => load_lines_from_json(&mut raw_lines, path).with_context(|| format!("failed to load lines from {path:?}"))?, Some("zip") => load_lines_from_zip(&mut raw_lines, path).with_context(|| format!("failed to load lines from {path:?}"))?, _ => eprintln!("unknown file extension: '{}'", path.to_string_lossy()), @@ -142,7 +146,7 @@ fn load_lines_from_zip( .by_index(i) .with_context(|| format!("failed to get file with index {i} from zip"))?; - if !f.is_file() || !f.name().ends_with(".json") { + if !f.is_file() || !f.name().to_ascii_lowercase().ends_with(".json") { continue; }