feat: add versioning

This commit is contained in:
2026-07-30 11:56:27 +02:00
parent e045bd39b2
commit 033b0bb5be
6 changed files with 74 additions and 1 deletions

17
cli.go
View File

@@ -8,6 +8,17 @@ import (
var completionShells = []string{"bash", "zsh", "fish"}
func handleVersionCommand(args []string, output io.Writer) (bool, error) {
if len(args) == 0 || args[0] != "--version" {
return false, nil
}
if len(args) != 1 {
return true, fmt.Errorf("usage: diple --version")
}
_, err := fmt.Fprintf(output, "diple %s\n", dipleVersion)
return true, err
}
func handleCompletionCommand(args []string, output io.Writer) (bool, error) {
if len(args) == 0 || args[0] != "completion" {
return false, nil
@@ -55,6 +66,7 @@ func writeCLIHelp(output io.Writer, defaults Config, configPath string) {
Usage:
diple [options]
diple --version
diple completion <bash|zsh|fish>
diple help
@@ -92,6 +104,7 @@ Local state:
Other:
-h, --help Show this help and exit.
--version Show the application version and exit.
Boolean options accept explicit values, for example --cache=false.
Command-line options override TOML settings. GH_REPO is used only when
@@ -158,7 +171,7 @@ _diple_completion() {
;;
esac
local options="--repo --all --limit --poll --endpoint --theme --dashboard-mode --thread-list-width --fold-resolved --compact-reviews --path-scroll --path-scroll-interval --editor-mode --config --cache --cache-max-age --cache-dir --help -h"
local options="--repo --all --limit --poll --endpoint --theme --dashboard-mode --thread-list-width --fold-resolved --compact-reviews --path-scroll --path-scroll-interval --editor-mode --config --cache --cache-max-age --cache-dir --version --help -h"
COMPREPLY=($(compgen -W "${options}" -- "${current}"))
}
complete -F _diple_completion diple
@@ -202,6 +215,7 @@ _diple() {
'--cache=[enable local read cache]:boolean:(true false)' \
'--cache-max-age[maximum offline cache age]:duration:' \
'--cache-dir[local read-cache directory]:directory:_directories' \
'--version[show application version]' \
'(-h --help)'{-h,--help}'[show help]'
}
@@ -234,5 +248,6 @@ complete -c diple -l config -r -F -d 'TOML configuration file'
complete -c diple -l cache -d 'Enable local read cache'
complete -c diple -l cache-max-age -x -d 'Maximum offline cache age'
complete -c diple -l cache-dir -r -a '(__fish_complete_directories)' -d 'Local read-cache directory'
complete -c diple -l version -d 'Show application version'
complete -c diple -s h -l help -d 'Show help'
`