]> Sergey Matveev's repositories - schwabrak.git/commitdiff
Another simplification master
authorSergey Matveev <stargrave@stargrave.org>
Thu, 20 Mar 2025 08:58:01 +0000 (11:58 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Fri, 28 Mar 2025 15:03:32 +0000 (18:03 +0300)
README
add
brief [deleted file]
cd
full
metas [new file with mode: 0755]
rc.sh [deleted file]
schemas [new file with mode: 0755]
show [new file with mode: 0755]
uuidv7 [deleted file]

diff --git a/README b/README
index 3d4abc8998596c701c8b04c46c79771b1f5b713cdee23d45ebb39ae7cbe7f974..3a2a27582693d5bf15271da758f7a124e240e81edb9e73432555956108473a1e 100644 (file)
--- a/README
+++ b/README
@@ -1,7 +1,7 @@
 schwabrak -- simple flat file based issue tracker
 
-Note: this is the second version/iteration/suggestion. Look for previous
-one in older commits.
+Note: this is the second version/iteration/suggestion.
+Look for previous one in older commits.
 
 I want a relatively simple issue/ticket tracker. Something like Trac,
 Redmine or Fossil. But they require heavy dependencies (Python, Ruby),
@@ -34,9 +34,47 @@ name to a human readable issue title, as PoormanIssueTracker suggests.
 
 The "about" file contains the description of the issue. The "result"
 (initially empty) contains the resolved issue information. The "meta"
-file contains metainformation in recfile format, having at least "id"
-and "created" fields. The issue.rec file contains the schema of the
-records in current issues database. https://www.gnu.org/software/recutils/
+file contains metainformation in recfile format, having at least
+"created" fields. https://www.gnu.org/software/recutils/
+
+Root directory should contain *.rec files with the schema of the
+records. For example:
+
+    person.rec:
+        %rec: person
+        %key: id
+        %unique: name
+        %mandatory: name email
+        %type: id line
+        %type: name line
+        %type: email email
+
+        id: stargrave
+        name: Сергей Матвеев
+        email: stargrave@stargrave.org
+
+    task.rec:
+        %rec: task
+        %key: id
+        %mandatory: name created
+        %unique: name created about result
+        %allowed: about result ass proj status
+        %sort: created
+        %type: id line
+        %type: name line
+        %type: created date
+        %type: ass rec person
+        %type: proj enum
+        + c (C99)
+        + go (Go)
+        + py (Python3)
+        + tcl (Tcl)
+        %type: status enum
+        + done (task is finished)
+        + reject
+        + wip (work in progress)
+
+Schema of the issues/tasks must be trailing *.rec file after the sort.
 
 Want to search among the issues? Just use git grep, or ordinary grep!
 Want to search through attached PDFs or other kind of documents? You are
@@ -49,9 +87,11 @@ human-friendly format) or with recset utility. Add "deps: foo-bar" field
 and press "gf" in your Vi editor to go to "foo-bar" directory of the
 dependant issue.
 
-"full" script exports the whole issues database with the prepended
-issue.rec to stdout, including "about" and "result" fields. It is
-expected to be filtered with recsel/recdel utilities.
+"metas" script exports the whole issues database without about/result
+fields. "show" includes them. "full" also prepends *.rec files to the
+output. They are expected to be filtered with recsel/recdel utilities.
+"cd" lists all issues piped to "fzf" utility, that previews each one
+with "show" script.
 
 The "comment" issue's file is intended to keep the last comment related to
 the issue. By committing it you automatically accompany it with your
@@ -78,9 +118,3 @@ To ease the creation of the new issue's directory structure, you can use
 "add" command as seen above. And yes, it is intended that "issue" and
 "name", "to", "create" can be passed as separate arguments, but
 issue-name-to-create will be created as expected.
-
-"brief" lists all issues same way as "full", but without about/result
-fields. It does not require recutils installed.
-
-"cd" lists all issues piped to "fzf" utility, that previews each one
-with "full" script.
diff --git a/add b/add
index c0188c9626ead47bcd4d0cb8c6cc370c04d55dd46b74d17db2459339fa5fc40c..2f097b35a15ba403ef7a9dcbc25151d77773701d675e031ca2abb3fec3baf984 100755 (executable)
--- a/add
+++ b/add
@@ -1,14 +1,14 @@
 #!/bin/sh -e
 
+endash() {
+    ${PERL:-perl} -npe 's/(-+)/$1-/g ; s/ /-/g'
+}
+
 SROOT="$(dirname "$(realpath -- "$0")")"
-. "$SROOT/rc.sh"
 fn="$@"
 fn="$(dirname "$fn")/$(basename "$fn" | endash)"
 mkdir "$fn"
-cat >"$fn"/meta <<EOF
-id: $($SROOT/uuidv7)
-created: $(date -u +"%Y-%m-%d %H:%M:%S")
-EOF
+echo created: $(date -u +"%Y-%m-%d %H:%M:%S") >"$fn"/meta
 touch "$fn"/about "$fn"/result
 $EDITOR "$fn"/about
 git add "$fn"
diff --git a/brief b/brief
deleted file mode 100755 (executable)
index 6aceadc..0000000
--- a/brief
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh -e
-
-SROOT="$(dirname "$(realpath -- "$0")")"
-. $SROOT/rc.sh
-
-cat issue.rec
-echo
-for i in $(_list $1) ; do
-    echo name: $i
-    cat $i/meta
-    echo
-done
diff --git a/cd b/cd
index 6e2cc818d8444f2754295109dd73ff2e0307b17f9d2dc9faceb81f5880c4d047..5551a3135ee3b371c1d317cdb579a8abd6021b3049f4bfaee733fcc6811fdae3 100755 (executable)
--- a/cd
+++ b/cd
@@ -1,8 +1,7 @@
 #!/bin/sh -e
 
 SROOT="$(dirname "$(realpath -- "$0")")"
-. $SROOT/rc.sh
-_list . | fzf --ansi --tac \
+$SROOT/metas | recfix --sort | recsel -C -P id | fzf --ansi \
     --bind=ctrl-e:preview-page-down \
     --bind=ctrl-y:preview-page-up \
-    --preview="$SROOT/full {1} | recsel"
+    --preview="$SROOT/show {1}"
diff --git a/full b/full
index 46fa21969b105227b4bbd0fe73096f6c2e9485b4db30eb17a8c2a5906e2ffb32..816db75ac02d7124fa7c2e6101edf6ac75febcce2b84d5c08f5615c2f4e27fba 100755 (executable)
--- a/full
+++ b/full
@@ -1,15 +1,5 @@
 #!/bin/sh -e
 
 SROOT="$(dirname "$(realpath -- "$0")")"
-. $SROOT/rc.sh
-
-cat issue.rec
-echo
-for i in $(_list $1) ; do
-    echo name: $i
-    cat $i/meta
-    echo | recins \
-        -f about -v "$(echo ; cat $i/about)" \
-        -f result -v "$(echo ; cat $i/result)"
-    echo
-done
+$SROOT/schemas
+$SROOT/show $@
diff --git a/metas b/metas
new file mode 100755 (executable)
index 0000000..d90c219
--- /dev/null
+++ b/metas
@@ -0,0 +1,10 @@
+#!/bin/sh -e
+
+for i in $(find ${1:-.} -type d) ; do
+    i=${i#./}
+    [ -s $i/meta ] || continue
+    echo id: $i
+    echo name: $i | ${PERL:-perl} -npe 's/([^-])-([^-])/$1 $2/g ; s/-(-+)/$1/g'
+    cat $i/meta
+    echo
+done
diff --git a/rc.sh b/rc.sh
deleted file mode 100644 (file)
index bb97bc2..0000000
--- a/rc.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-endash() {
-    ${PERL:-perl} -npe 's/(-+)/$1-/g ; s/ /-/g'
-}
-
-_list() {
-    what=${1:-.}
-    for i in $(find $what -type d) ; do
-        i=${i#./}
-        [ -s $i/meta ] || continue
-        echo $i
-    done
-}
diff --git a/schemas b/schemas
new file mode 100755 (executable)
index 0000000..e7b24b7
--- /dev/null
+++ b/schemas
@@ -0,0 +1,6 @@
+#!/bin/sh -e
+
+for i in $(find . -name "*.rec" -maxdepth 1 | sort -n) ; do
+    cat $i
+    echo
+done
diff --git a/show b/show
new file mode 100755 (executable)
index 0000000..31fb4ef
--- /dev/null
+++ b/show
@@ -0,0 +1,11 @@
+#!/bin/sh -e
+
+SROOT="$(dirname "$(realpath -- "$0")")"
+{ $SROOT/schemas ; $SROOT/metas $1 ; } |
+recfix --sort | recsel -t task -C -P id |
+while read i ; do
+    $SROOT/metas $i |
+        recset -f about -S "$(echo ; cat $i/about)" |
+        recset -f result -S "$(echo ; cat $i/result)"
+    echo
+done
diff --git a/uuidv7 b/uuidv7
deleted file mode 100755 (executable)
index 83ec83c..0000000
--- a/uuidv7
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env perl
-
-use strict;
-use warnings;
-
-my $len = 10;
-my $v;
-open(my $rnd, "/dev/urandom") or die "open(urandom): $!";
-die "read(urandom) != $len" if (read($rnd, $v, $len) != $len);
-close $rnd;
-my @a = unpack "C*", ("000000" . $v);
-
-use Time::HiRes qw(gettimeofday);
-my ($sec, $ms) = gettimeofday();
-my $ts = int($sec * 1000 + $ms / 1000);
-
-$a[0] = ($ts >> 40) & 0xFF;
-$a[1] = ($ts >> 32) & 0xFF;
-$a[2] = ($ts >> 24) & 0xFF;
-$a[3] = ($ts >> 16) & 0xFF;
-$a[4] = ($ts >> 8) & 0xFF;
-$a[5] = $ts & 0xFF;
-
-$a[6] = ($a[6] | 0x0F) | 0x70;
-$a[8] = ($a[8] | 0x3F) | 0x80;
-
-print join("-", map { unpack("H*", pack("C*", @$_)) } (
-    [@a[0..3]], [@a[4..5]], [@a[6..7]], [@a[8..9]], [@a[10..15]],
-)) . "\n";