diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2025-07-02 21:57:16 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska@appnovation.com> | 2025-07-02 21:57:16 +0000 |
| commit | 7f0aa026e16989584f4d79e50fbe75f5558a00f8 (patch) | |
| tree | 09f0383badf6791d94e632de89350490b63404c9 /src/repo | |
| parent | 7e24694e178c1dbe105b6ef77d62ba4e9f6b622a (diff) | |
| download | s6-rc-7f0aa026e16989584f4d79e50fbe75f5558a00f8.tar.gz | |
s6-rc-repo-init: better error messages
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/repo')
| -rw-r--r-- | src/repo/s6-rc-repo-init.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/repo/s6-rc-repo-init.c b/src/repo/s6-rc-repo-init.c index d358e1a..14c34d7 100644 --- a/src/repo/s6-rc-repo-init.c +++ b/src/repo/s6-rc-repo-init.c @@ -41,22 +41,35 @@ static gol_bool const rgolb[1] = { .so = 'f', .lo = "force", .clear = 0, .set = 1 << GOLB_FORCE } } ; -static gol_arg const rgola[1] = +enum gola_e { - { .so = 'r', .lo = "repodir", .i = 0 } + GOLA_VERBOSITY, + GOLA_REPODIR, + GOLA_N +} ; + +static gol_arg const rgola[2] = +{ + { .so = 'v', .lo = "verbosity", .i = GOLA_VERBOSITY }, + { .so = 'r', .lo = "repodir", .i = GOLA_REPODIR } } ; int main (int argc, char const *const *argv) { size_t repolen ; char const *repo = S6RC_REPO_BASE ; + unsigned int verbosity = 1 ; + mode_t m ; + char const *wgola[2] = { 0 } ; uint64_t wgolb = 0 ; unsigned int golc ; - mode_t m ; PROG = "s6-rc-repo-init" ; - golc = gol_main(argc, argv, rgolb, 1, rgola, 1, &wgolb, &repo) ; + golc = gol_main(argc, argv, rgolb, 1, rgola, 2, &wgolb, wgola) ; argc -= golc ; argv += golc ; + if (wgola[GOLA_VERBOSITY] && !uint0_scan(wgola[GOLA_VERBOSITY], &verbosity)) + strerr_dief1x(100, "verbosity needs to be an unsigned integer") ; + if (wgola[GOLA_REPODIR]) repo = wgola[GOLA_REPODIR] ; if (repo[0] != '/') strerr_dief2x(100, repo, " is not an absolute path") ; for (unsigned int i = 0 ; i < argc ; i++) @@ -103,7 +116,7 @@ int main (int argc, char const *const *argv) umask(m) ; - if (!s6rc_repo_sync(repotmp, argv, argc)) + if (!s6rc_repo_sync(repotmp, argv, argc, verbosity)) { cleanup(repotmp) ; strerr_diefu2sys(111, "sync ", repotmp) ; |
