]> hydra-www.ietfng.org Git - csdb/commitdiff
Adjust readme and error report for CDB env var
authorNathaniel Wesley Filardo <nwfilardo@gmail.com>
Sun, 8 May 2022 23:00:22 +0000 (00:00 +0100)
committerNathaniel Wesley Filardo <nwfilardo@gmail.com>
Sun, 8 May 2022 23:00:22 +0000 (00:00 +0100)
Further work on 4e024464739fe314855ef66e797ae45cb23007be

README.rst
cdb

index afb18cb8d1a135d0860e0eade8981d26ca4d4116..7f3be8b3857aa0f4206ea3dd14851bf426580b55 100644 (file)
@@ -102,7 +102,7 @@ We can generate the list of files we don't know about using ``find`` and
 ``cdb filterpath``::
 
    find ${DIR} -type f -print0 | \
-     cdb --db ${DB} filterpath --inul --format '$u$z' --nul > ${DB}.new-files0
+     cdb filterpath -1 -P -p out -0 -f '$u$z' > ${DB}.new-files0
 
 .. _xargs_sha:
 
@@ -127,7 +127,7 @@ file system as follows::
 This database may not seem very useful, but when combined with ``cdb --db diff`` we
 can quickly find all paths whose checksums are unknown to the database::
 
-   cdb --db ${DB} diff ${JPDB} --flavor=path --which=super --format '$u$z' --nul > ${DB}.new-files0
+   cdb diff ${JPDB} --no-headers --flavor=path --which=super --format '$u$z' -0 > ${DB}.new-files0
 
 And then proceed as `above <xargs_sha>`_.
 
@@ -147,9 +147,9 @@ Armed with a "just paths" database as per the above, we can then direct the
 database to prune tracked paths not in the "just paths" database if the hashes
 are observed elsewhere::
 
-   cdb --db ${DB} diff ${JPDB} --flavor=path --which=sub --no-headers --format '$u$z' --nul > ${JPDB}.missing-files0
-   cdb --db ${DB} domv --inul < ${JPDB}.missing-files0
-   cdb --db ${DB} gc > ${DB}.gc
+   cdb diff ${JPDB} --flavor=path --which=sub --no-headers --format '$u$z' --nul > ${JPDB}.missing-files0
+   cdb domv --inul < ${JPDB}.missing-files0
+   cdb gc > ${DB}.gc
    sqlite3 ${DB} < ${DB}.gc
 
 .. TODO or if the observed digest is now superseded?
@@ -242,7 +242,7 @@ presence elsewhere in the database.  We can enumerate files not tracked using
 above::
 
    find ${DIR} -type f -print0 | \
-   cdb --db ${DB} filterpath --in-path --predicate=out -0 -1 --format '$u$z' | \
+   cdb filterpath --in-path --predicate=out -0 -1 --format '$u$z' | \
    xargs -0 sha512sum > ${DB}.new
 
 We can then prepare to prune duplicates and add unique files::
diff --git a/cdb b/cdb
index 1bad82ca862787caf5916edac9628a96f4256622..a88a3c79c97ed1bb2c1d005a4c1190e38da599a3 100755 (executable)
--- a/cdb
+++ b/cdb
@@ -1139,7 +1139,9 @@ for k,v in pairs(argp_groups) do argp:group(k, table.unpack(v)) end
 local args = argp:parse()
 -- io.stderr:write((require "pl.pretty").write(args), "\n")
 
-if not args.database then argp:error("Database is required") end
+if not args.database then
+  argp:error("Database is required; pass --db or set CDB env var")
+end
 
 local dbh, err = dbi.Connect("SQLite3", args.database)
 if not dbh then