integrii / flaggy

Idiomatic Go input parsing with subcommands, positional values, and flags at any position. No required project or package layout and no external dependencies.
The Unlicense
859 stars 31 forks source link

Text aligment of help output #74

Open rfjakob opened 3 years ago

rfjakob commented 3 years ago

I'm trying to migrate https://github.com/rfjakob/gocryptfs from stdlib to flaggy. It's nice so far, having slice types is great, binding positional arguments is great, but is there a way to align the help output?

$ ./gocryptfs -hh
gocryptfs v2.0.1-43-gb67c678.flaggy; go-fuse v2.1.1-0.20210802120645-15a8bb029a4e; 2021-08-09 go1.16.5 linux/amd64

Usage: gocryptfs -init|-passwd|-info [OPTIONS] CIPHERDIR
  or   gocryptfs [OPTIONS] CIPHERDIR MOUNTPOINT

Options:
gocryptfs

  Usage:
    gocryptfs [CIPHERDIR] [MOUNTPOINT]

  Positional Variables: 
    CIPHERDIR    ciphertext directory
    MOUNTPOINT   mountpoint
  Flags: 
    -h --help               Displays help with available flag, subcommand, and positional value parameters.
    -d 
    -debug                    Enable debug output
    -fusedebug                    Enable fuse library debug output
    -init                    Initialize encrypted directory
    -zerokey                    Use all-zero dummy master key
    -openssl                    Use OpenSSL instead of built-in Go crypto (default: auto)
    -passwd                    Change password
    -f 
    -fg                    Stay in the foreground
    -version                    Print version and exit
    -plaintextnames                    Do not encrypt file names
    -q 
    -quiet                    Quiet - silence informational messages
    -nosyslog                    Do not redirect output to syslog when running in the background
    -wpanic                    When encountering a warning, panic and exit immediately
    -longnames                    Store names longer than 176 bytes in extra files (default: true)
    -allow_other                    Allow other users to access the filesystem. Only works if user_allow_other is set in /etc/fuse.conf.
    -reverse                    Reverse mode
    -aessiv                    AES-SIV encryption
    -nonempty                    Allow mounting over non-empty directories
    -raw64                    Use unpadded base64 for file names (default: true)
    -noprealloc                    Disable preallocation before writing
    -speed                    Run crypto speed test
    -hkdf                    Use HKDF as an additional key derivation step (default: true)
    -serialize_reads                    Try to serialize read operations
    -forcedecode                    Force decode of files even if integrity check fails. Requires gocryptfs to be compiled with openssl support and implies -openssl true
    -hh                    Show this long help text (default: false)
    -info                    Display information about CIPHERDIR
    -sharedstorage                    Make concurrent access to a shared CIPHERDIR safer
    -devrandom                    Use /dev/random for generating master key
    -fsck                    Run a filesystem check on CIPHERDIR
    -dev                    Allow device files
    -nodev                    Deny device files
    -suid                    Allow suid binaries
    -nosuid                    Deny suid binaries
    -exec                    Allow executables
    -noexec                    Deny executables
    -rw                    Mount the filesystem read-write
    -ro                    Mount the filesystem read-only
    -kernel_cache                    Enable the FUSE kernel_cache option
    -acl                    Enforce ACLs
    -masterkey                    Mount with explicit master key
    -cpuprofile                    Write cpu profile to specified file
    -memprofile                    Write memory profile to specified file
    -config                    Use specified config file instead of CIPHERDIR/gocryptfs.conf
    -ko                    Pass additional options directly to the kernel, comma-separated list
    -ctlsock                    Create control socket at specified path
    -fsname                    Override the filesystem name
    -force_owner                    uid:gid pair to coerce ownership
    -trace                    Write execution trace to file
    -fido2                    Protect the masterkey using a FIDO2 token instead of a password
    -e --exclude            Exclude relative path from reverse view
    -ew --exclude-wildcard   Exclude path from reverse view, supporting wildcards
    -exclude-from                    File from which to read exclusion patterns (with -exclude-wildcard syntax)
    -extpass                    Use external program for the password prompt
    -badname                    Glob pattern invalid file names that should be shown
    -passfile                    Read password from file
    -notifypid                    Send USR1 to the specified process after successful mount - used internally for daemonization (default: 0)
    -scryptn                    scrypt cost parameter logN. Possible values: 10-28. A lower value speeds up mounting and reduces its memory needs, but makes the password susceptible to brute-force attacks (default: 16)
    -i --idle               Auto-unmount after specified idle duration (ignored in reverse mode). Durations are specified like "500s" or "2h45m". 0 means stay mounted indefinitely. (default: 0s)
    -nofail                    Ignored for /etc/fstab compatibility
    -o                    For compatibility with mount(1), options can be also passed as a comma-separated list to -o on the end.
integrii commented 2 years ago

Oof. I agree that does not look great. We could put some logic in to determine how many tabs to use when displaying help output like that to fix things up... Sorry for the mega-delayed reply. This would be a great enhancement.

If you don't mind me asking, was this what caused gocryptfs to ultimately move away from using flaggy?