1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-18 14:47:03 +00:00

chasquid-util: switch --configdir into --config_dir and deprecate --configdir

There's an inconsistency between chasquid (which uses `--config_dir`) and
chasquid-util (which uses `--configdir`).

That is prone to cause confusion, so this patch renames chasquid-util's
flag, leaving the old one as deprecated with a warning message.

Closes https://github.com/albertito/chasquid/pull/60.

Amended-by: Alberto Bertogli <albertito@blitiri.com.ar>
  Added test case for the deprecated option, adjusted commit message.
This commit is contained in:
Albert ARIBAUD
2025-03-21 15:02:03 +01:00
committed by Alberto Bertogli
parent e5e7256d3e
commit fa074ec16c
6 changed files with 39 additions and 14 deletions

View File

@@ -48,8 +48,8 @@ Usage:
private key.
Options:
-C=<path>, --configdir=<path> Configuration directory
-v Verbose mode
-C=<path>, --config_dir=<path> Configuration directory
-v Verbose mode
`
// Command-line arguments.
@@ -74,12 +74,16 @@ func main() {
}
// Load globals.
if d, ok := args["--configdir"]; ok {
if d, ok := args["--config_dir"]; ok {
configDir = d
}
if d, ok := args["-C"]; ok {
configDir = d
}
if d, ok := args["--configdir"]; ok {
configDir = d
Warnf("Option --configdir is deprecated, use --config_dir instead")
}
commands := map[string]func(){
"user-add": userAdd,
@@ -114,6 +118,11 @@ func Fatalf(s string, arg ...interface{}) {
os.Exit(1)
}
// Warnf prints the given message to stderr, but does not exit the program.
func Warnf(s string, arg ...interface{}) {
fmt.Fprintf(os.Stderr, s+"\n", arg...)
}
func userDBForDomain(domain string) string {
if domain == "" {
domain = args["$2"]