From 599435f1ab7b1290453931e4c8d3951618bac14d Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 9 Jun 2025 18:18:34 +0300 Subject: [PATCH] update `export-svg` to `target-svg` update usage example --- README.md | 13 +++++++------ src/argument.rs | 4 ++-- src/main.rs | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index c05d6ce..3a0fda4 100644 --- a/README.md +++ b/README.md @@ -28,10 +28,11 @@ Export totals in multiple formats, such as JSON or SVG [badge](https://github.co ## Usage ``` bash -htcount --source /var/log/nginx/access.log\ - --export-json /path/to/totals.json\ - --export-svg /path/to/totals.svg +htcount --source /var/log/nginx/access.log\ + --target-svg /path/to/badge.svg\ + --template-svg /path/to/counter/template.svg ``` +* see `default/counter.svg` ### Options @@ -50,10 +51,10 @@ htcount --source /var/log/nginx/access.log\ [default: nginx] ---export-json +--target-json Export results to JSON file (e.g. `/path/to/stats.json`) ---export-svg +--target-svg Export results to SVG file (e.g. `/path/to/badge.svg`) * use `{hits}` / `{hosts}` pattern to replace parsed values @@ -101,7 +102,7 @@ Wants=network-online.target [Service] Type=simple ExecStart=/usr/local/bin/htcount --source /var/log/nginx/access.log\ - --export-svg /var/www/htcount/visitors.svg\ + --target-svg /var/www/htcount/visitors.svg\ --template-svg /path/to/default/template.svg\ --ignore-host 127.0.0.1\ --ignore-host 127.0.0.2\ diff --git a/src/argument.rs b/src/argument.rs index 4449d74..c7b1663 100644 --- a/src/argument.rs +++ b/src/argument.rs @@ -18,13 +18,13 @@ pub struct Argument { /// Export results to JSON file (e.g. `/path/to/stats.json`) #[arg(long)] - pub export_json: Option, + pub target_json: Option, /// Export results to SVG file (e.g. `/path/to/badge.svg`) /// /// * use `{hits}` / `{hosts}` pattern to replace parsed values #[arg(long)] - pub export_svg: Option, + pub target_svg: Option, /// Use custom SVG file template with `{hits}` / `{hosts}` placeholders #[arg(long, default_value_t = String::from("default/counter.svg"))] diff --git a/src/main.rs b/src/main.rs index d218506..11c6597 100644 --- a/src/main.rs +++ b/src/main.rs @@ -90,12 +90,12 @@ fn main() -> anyhow::Result<()> { )); } - if let Some(ref p) = argument.export_json { + if let Some(ref p) = argument.target_json { let mut f = File::create(p)?; f.write_all(format!("{{\"hosts\":{hosts},\"hits\":{hits}}}").as_bytes())?; } - if let Some(ref p) = argument.export_svg { + if let Some(ref p) = argument.target_svg { let t = std::fs::read_to_string(&argument.template_svg)?; let mut f = File::create(p)?; f.write_all(