/
githubmirror
/
photoprism
Обзор
Документация
Войти
/
githubmirror
/
photoprism
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
internal/commands/path_args.go
35 строк
831 B
Michael Mayer
CLI: Standardize path validation and exit codes #5457
24 фев 2026, 01:00
24 фев 2026, 01:00
3f8e74f
Код
Авторство
О чём код?
package commands import ( "strings" "github.com/urfave/cli/v2" "github.com/photoprism/photoprism/pkg/clean" ) // sanitizeSubfolderArg normalizes a subfolder argument and returns an exit-coded // error when a non-empty value is invalid. func sanitizeSubfolderArg(raw string) (string, error) { raw = strings.TrimSpace(raw) subPath := clean.UserPath(raw) if raw != "" && subPath == "" { return "", cli.Exit("invalid subfolder path", 2) } return subPath, nil } // sanitizeDestinationArg normalizes a destination flag value and returns an // exit-coded error when a non-empty value is invalid. func sanitizeDestinationArg(raw string) (string, error) { raw = strings.TrimSpace(raw) dest := clean.UserPath(raw) if raw != "" && dest == "" { return "", cli.Exit("invalid destination path", 2) } return dest, nil }