From 9cd60dc8ebad015460806bf9d3f09c46cecd8b9b Mon Sep 17 00:00:00 2001 From: Christian Zangl Date: Wed, 21 Aug 2024 21:45:31 +0200 Subject: [PATCH] improve help --- README.md | 9 +++++---- cmd/chkbit/help.go | 2 +- cmd/chkbit/main.go | 15 +++++++++------ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 95e84ea..0ed2e9b 100644 --- a/README.md +++ b/README.md @@ -84,16 +84,17 @@ Arguments: Flags: -h, --help Show context-sensitive help. -H, --tips Show tips. - -u, --update update indices (without this chkbit will verify files in readonly mode) - -i, --show-ignored-only only show ignored files (will not check hashes in this mode) + -c, --check check mode: chkbit will verify files in readonly mode (default mode) + -u, --update update mode: add and update indices + -i, --show-ignored-only show-ignored mode: only show ignored files -m, --show-missing show missing files/directories - --algo="blake3" hash algorithm: md5, sha512, blake3 (default: blake3) - --force force update of damaged items + --force force update of damaged items (advanced usage only) -S, --skip-symlinks do not follow symlinks -R, --no-recurse do not recurse into subdirectories -D, --no-dir-in-index do not track directories in the index -l, --log-file=STRING write to a logfile if specified --log-verbose verbose logging + --algo="blake3" hash algorithm: md5, sha512, blake3 (default: blake3) --index-name=".chkbit" filename where chkbit stores its hashes, needs to start with '.' (default: .chkbit) --ignore-name=".chkbitignore" filename that chkbit reads its ignore list from, needs to start with '.' (default: .chkbitignore) -w, --workers=5 number of workers to use (default: 5) diff --git a/cmd/chkbit/help.go b/cmd/chkbit/help.go index babcd2c..02a9e93 100644 --- a/cmd/chkbit/help.go +++ b/cmd/chkbit/help.go @@ -1,6 +1,6 @@ package main -var headerHelp = `Checks the data integrity of your files. +var headerHelp = `Checks the data integrity of your files. For help tips run "chkbit -H" or go to https://github.com/laktak/chkbit ` diff --git a/cmd/chkbit/main.go b/cmd/chkbit/main.go index 2383bb6..2011534 100644 --- a/cmd/chkbit/main.go +++ b/cmd/chkbit/main.go @@ -44,16 +44,17 @@ var ( var cli struct { Paths []string `arg:"" optional:"" name:"paths" help:"directories to check"` Tips bool `short:"H" help:"Show tips."` - Update bool `short:"u" help:"update indices (without this chkbit will verify files in readonly mode)"` - ShowIgnoredOnly bool `short:"i" help:"only show ignored files (will not check hashes in this mode)"` + Check bool `short:"c" help:"check mode: chkbit will verify files in readonly mode (default mode)"` + Update bool `short:"u" help:"update mode: add and update indices"` + ShowIgnoredOnly bool `short:"i" help:"show-ignored mode: only show ignored files"` ShowMissing bool `short:"m" help:"show missing files/directories"` - Algo string `default:"blake3" help:"hash algorithm: md5, sha512, blake3 (default: blake3)"` - Force bool `help:"force update of damaged items"` + Force bool `help:"force update of damaged items (advanced usage only)"` SkipSymlinks bool `short:"S" help:"do not follow symlinks"` NoRecurse bool `short:"R" help:"do not recurse into subdirectories"` NoDirInIndex bool `short:"D" help:"do not track directories in the index"` LogFile string `short:"l" help:"write to a logfile if specified"` LogVerbose bool `help:"verbose logging"` + Algo string `default:"blake3" help:"hash algorithm: md5, sha512, blake3 (default: blake3)"` IndexName string `default:".chkbit" help:"filename where chkbit stores its hashes, needs to start with '.' (default: .chkbit)"` IgnoreName string `default:".chkbitignore" help:"filename that chkbit reads its ignore list from, needs to start with '.' (default: .chkbitignore)"` Workers int `short:"w" default:"5" help:"number of workers to use (default: 5)"` @@ -155,8 +156,10 @@ func (m *Main) showStatus() { } func (m *Main) process() bool { - if cli.Update && cli.ShowIgnoredOnly { - fmt.Println("Error: use either --update or --show-ignored-only!") + // verify mode + var b01 = map[bool]int8{false: 0, true: 1} + if b01[cli.Check]+b01[cli.Update]+b01[cli.ShowIgnoredOnly] > 1 { + fmt.Println("Error: can only run one mode at a time!") return false }