improve help

This commit is contained in:
Christian Zangl 2024-08-21 21:45:31 +02:00
parent ef18e44ef0
commit 9cd60dc8eb
No known key found for this signature in database
GPG Key ID: 6D468AC36E2A4B3D
3 changed files with 15 additions and 11 deletions

View File

@ -84,16 +84,17 @@ Arguments:
Flags: Flags:
-h, --help Show context-sensitive help. -h, --help Show context-sensitive help.
-H, --tips Show tips. -H, --tips Show tips.
-u, --update update indices (without this chkbit will verify files in readonly mode) -c, --check check mode: chkbit will verify files in readonly mode (default mode)
-i, --show-ignored-only only show ignored files (will not check hashes in this 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 -m, --show-missing show missing files/directories
--algo="blake3" hash algorithm: md5, sha512, blake3 (default: blake3) --force force update of damaged items (advanced usage only)
--force force update of damaged items
-S, --skip-symlinks do not follow symlinks -S, --skip-symlinks do not follow symlinks
-R, --no-recurse do not recurse into subdirectories -R, --no-recurse do not recurse into subdirectories
-D, --no-dir-in-index do not track directories in the index -D, --no-dir-in-index do not track directories in the index
-l, --log-file=STRING write to a logfile if specified -l, --log-file=STRING write to a logfile if specified
--log-verbose verbose logging --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) --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) --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) -w, --workers=5 number of workers to use (default: 5)

View File

@ -1,6 +1,6 @@
package main 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 For help tips run "chkbit -H" or go to
https://github.com/laktak/chkbit https://github.com/laktak/chkbit
` `

View File

@ -44,16 +44,17 @@ var (
var cli struct { var cli struct {
Paths []string `arg:"" optional:"" name:"paths" help:"directories to check"` Paths []string `arg:"" optional:"" name:"paths" help:"directories to check"`
Tips bool `short:"H" help:"Show tips."` Tips bool `short:"H" help:"Show tips."`
Update bool `short:"u" help:"update indices (without this chkbit will verify files in readonly mode)"` Check bool `short:"c" help:"check mode: chkbit will verify files in readonly mode (default mode)"`
ShowIgnoredOnly bool `short:"i" help:"only show ignored files (will not check hashes in this 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"` 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 (advanced usage only)"`
Force bool `help:"force update of damaged items"`
SkipSymlinks bool `short:"S" help:"do not follow symlinks"` SkipSymlinks bool `short:"S" help:"do not follow symlinks"`
NoRecurse bool `short:"R" help:"do not recurse into subdirectories"` NoRecurse bool `short:"R" help:"do not recurse into subdirectories"`
NoDirInIndex bool `short:"D" help:"do not track directories in the index"` NoDirInIndex bool `short:"D" help:"do not track directories in the index"`
LogFile string `short:"l" help:"write to a logfile if specified"` LogFile string `short:"l" help:"write to a logfile if specified"`
LogVerbose bool `help:"verbose logging"` 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)"` 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)"` 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)"` 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 { func (m *Main) process() bool {
if cli.Update && cli.ShowIgnoredOnly { // verify mode
fmt.Println("Error: use either --update or --show-ignored-only!") 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 return false
} }