hlfw.ca

task

Download patch

ref: 57a3cb892d1df2f3787531e0ead84c8e943744ea
parent: 932aa079d1f8a98ba1d50e7bb4b3ea876053125c
author: Michael Misch <michaelmisch1985@gmail.com>
date: Wed Aug 28 22:46:38 PDT 2024

Update the readme, shuffle binaries

--- a/README.md
+++ b/README.md
@@ -1,27 +1,37 @@
-Project-specific namespaces
+## Config
 
-## Usage
+The config file in `.pro/config` is created by `pro/init`. `srvfile` and `stubs` are used by `pro/ns`, described below
 
-proj [i-] [-n nsdir] [-w wdir] [-s srvfile] project
+	[project "projectname"]
+		srvfile=/srv/foo
+		stubs=docs,resources
 
- - `-i` read project name from stdin
- - `-n` prefix for namespace files. (default `$home/lib/namespace,`)
- - `-w` location of your namespace. (default `/mnt/work`)
- - `-s` srv name. default `/srv/work`
+## Commands
 
-Given a project name, `proj` will set up a namespace based on `$home/lib/namespace.$projectname`. This will post an fd in /srv/work.
+`pro/init` is use to create a new barebones project, with no tasks or namespace files. If a name is given, the project will be created with that `name`, otherwase the basename of the directory is used. 
 
-## Example namespace
+`pro/ns` sets up a namespace based on the contents on `.pro/ns`, (see namespace(6)). This namespace is then posted to /srv/$name, based on the srvfile config setting. Any stubs in the config will be set up using `aux/stub -d $name` prior to starting the namespace
 
-	# assuming project has a docs/ dir with project-specific documents
-	bind /path/to/project /mnt/work
-	bind /path/to/additional/related/resources /mnt/work/docs
-	bind -a /path/to/other/resources /mnt/work/docs
-	
-	# You can also just include other namespace files
-	. /usr/glenda/lib/doc.namespace.resource
+See [this post](https://hlfw.ca/blog/2024-08-24-more-setup.html) for inspiration, and further integration.
 
-Now in any window related to your project, you can `mount /srv/work /mnt/work`
- - Useful for `acme /mnt/work`
+ `pro/task` is used to manage or add a task to the TODO graph, usage is similar to git/commit - the hold editor will be used by default, ctrl+d is used to signal completion. `-a $tag` will create the task as a child of `$tag`. `-b $tag` will create the task as a parent of `$tag`. `-c $tag` is used to change an existing task. Passing `-e` will use your default editor instead of hold mode. Any args afterwards will be passed along to the created task
 
-See [this post](https://hlfw.ca/blog/2024-08-24-more-setup.html) for inspiration, and further integration.
+`pro/rm` removes a given completed task. With `-f`, all matching tags are removed. With `-a`, all completed tags are checked for removal. 
+
+`pro/walk` shows the status of tasks in the graph. It prints a list of tasks prefixed with the status character.
+The -q option suppresses all output. The -f option filters tasks by status, and only patching items are printed. By default, the filters are DNS.
+
+The task status characters are as follows:
+
+- A	This task has been attempted, but is blocked
+- B	This task has not been attempted, and is blocked
+- D	This task is completed
+- N	This task has not been attempted
+- S	This task has been attempted
+
+*Blocked tasks have a child task that requires completing before they can be completed
+
+## TODO
+
+- `pro/walk` implementation
+- multi-project awareness for all utils. A task should be able to reference another project via a tag, such as `projectname:tag`
--- a/add
+++ /dev/null
@@ -1,80 +1,0 @@
-#!/bin/rc -e
-rfork ne
-
-# Remove commentary lines.
-# Remove leading and trailing empty lines.
-# Combine consecutive empty lines between paragraphs.
-# Remove trailing spaces from lines.
-# Ensure there's trailing newline.
-fn cleanmsg{
-	awk '
-	/^[ 	]*#/ {next}
-	/^[ 	]*$/ {empty = 1; next}
-
-	wet && empty {printf "\n"}
-	{wet = 1; empty = 0}
-	{sub(/[ 	]+$/, ""); print $0}
-	'
-}
-
-fn editmsg{
-	if(! test -s $msgfile.tmp){
-		>$msgfile.tmp {
-			echo -n '# tag:' $tag
-			if(! ~ $#before 0)
-				echo -n ' before:' $before
-			if(! ~ $#after 0)
-				echo -n ' after:' $after
-			echo ''
-			echo $data
-		}
-		edit=1
-	}
-	if(~ $#editor 0)
-		editor=hold
-	$editor $msgfile.tmp
-
-	cleanmsg < $msgfile.tmp > $msgfile
-	if(! test -s $msgfile){
-		echo 'empty task message' >[1=2]
-		exit 'task'
-	}
-}
-
-fn gettag{
-	files=`{ls .pro/todo/}
-	if(! ~ $#change 0)
-		tag=$change
-	if not
-		tag=$#files
-}
-
-fn final{
-	cp $msgfile .pro/todo/$tag
-}
-
-fn sigexit{
-	if(! ~ $#msgfile 0)
-		rm -f $msgfile $msgfile.tmp
-}
-
-flagfmt='c:change change, a:after after, b:before before, e:edit'; args='[msg ...]'
-eval `''{aux/getflags $*} || exec aux/usage
-
-msgfile=/tmp/pro-msg.$pid
-if(! ~ $#* 0){
-	data=`{echo $*}
-if(! ~ $#change 0 )
-	if(test -s .pro/todo/$change){
-		cat .pro/todo/$change > $msgfile.tmp
-		if(! ~ $#data 0)
-			echo $data >> $msgfile.tmp
-	}
-
-@{
-	flag e +
-	gettag
-	editmsg
-	final
-} || echo 'could not add task:' $status >[1=2]
-exit ''
--- a/proj.c
+++ /dev/null
@@ -1,119 +1,0 @@
-#include <u.h>
-#include <libc.h>
-#include <auth.h>
-#include <plumb.h>
-
-static void
-usage(void)
-{
-	fprint(2, "usage: %s [-p] [-i] [-n nsdir] [-w wdir] [-s srvfile] project\n", argv0);
-	exits("usage");
-}
-
-void
-main(int argc, char **argv)
-{
-	Plumbmsg *pm;
-	char *ename, *arglist[16], **argp;
-	char *user, *home, *wdir, *sfile, *plumb, *path;
-	int n, nb, fd, stdin, pfd, pipefd[2];
-	char buf[64], nsdir[64], pbuf[512];
-
-	argp = arglist;
-	home = nil;
-	ename = "/bin/exportfs";
-	wdir = "/mnt/work";
-	sfile = "/srv/work";
-	stdin = 0;
-	plumb = nil;
-	
-	*argp++ = "exportfs";
-	ARGBEGIN{
-	default:
-		usage();
-	case 'p':
-		plumb = EARGF(usage());
-		break;
-	case 'i':
-		stdin = 1;
-		break;
-	case 'n':
-		home = EARGF(usage());
-		strcpy(nsdir, home);
-		break;
-	case 'w':
-		wdir = EARGF(usage());
-		break;
-	case 's':
-		sfile = EARGF(usage());
-		break;
-	}ARGEND
-
-	if(argc != 1 && stdin != 1)
-		usage();
-	*argp++ = "-r";
-	*argp++ = wdir;
-	*argp = 0;
-
-	user = getuser();
-	if(!home){
-		home = getenv("home");
-		snprint(nsdir, sizeof nsdir, "%s/lib", home);
-	}
-
-	if(stdin){
-		n = snprint(buf, sizeof buf, "%s/namespace.", nsdir);
-		nb = read(0, buf+n, sizeof buf - n);
-		buf[n + nb - 1] = 0;
-		path = buf+n;
-	} else {
-		path = argv[0];
-		snprint(buf, sizeof buf, "%s/namespace.%s", nsdir, argv[0]);
-	}
-	execl("aux/stub", "-d", wdir);
-	if(addns(user, buf) < 0){
-		fprint(2, "can't addns: %r\n");
-		exits("addns");
-	}
-	if(pipe(pipefd) < 0){
-		fprint(2, "can't pipe: %r\n");
-		exits("pipe");
-	}
-	// Probably check for /srv/work existing and delete if so
-	if(access(sfile, 0) == 0)
-		remove(sfile);
-	fd = create(sfile, OWRITE|ORCLOSE, 0600);
-	if(fd < 0){
-		fprint(2, "can't create /srv/work: %r\n");
-		exits("create");
-	}
-	if(plumb){
-		// Messy, blegh.
-		snprint(pbuf, sizeof(pbuf), "plumb\n%s\n/mnt/work\ntext\nmessage=%s\n3\nnan", plumb, path);
-		pm = plumbunpack(pbuf, strlen(pbuf));
-		pfd = plumbopen("send", OWRITE);
-		plumbsend(pfd, pm);
-		close(pfd);
-		//plumbfree(pm);
-	}
-
-	fprint(fd, "%d", pipefd[1]);
-	close(pipefd[1]);
-
-	switch(rfork(RFPROC|RFNOWAIT|RFNOTEG|RFFDG)){
-	case -1:
-		fprint(2, "can't rfork: %r\n");
-		exits("rfork");
-	case 0:
-		dup(pipefd[0], 0);
-		dup(pipefd[0], 1);
-		close(pipefd[0]);
-
-		exec(ename, arglist);
-		fprint(2, "can't exec exportfs: %r\n");
-		exits("exec");
-	default:
-		break;
-	}
-	exits(0);
-}
--- /dev/null
+++ b/task
@@ -1,0 +1,80 @@
+#!/bin/rc -e
+rfork ne
+
+# Remove commentary lines.
+# Remove leading and trailing empty lines.
+# Combine consecutive empty lines between paragraphs.
+# Remove trailing spaces from lines.
+# Ensure there's trailing newline.
+fn cleanmsg{
+	awk '
+	/^[ 	]*#/ {next}
+	/^[ 	]*$/ {empty = 1; next}
+
+	wet && empty {printf "\n"}
+	{wet = 1; empty = 0}
+	{sub(/[ 	]+$/, ""); print $0}
+	'
+}
+
+fn editmsg{
+	if(! test -s $msgfile.tmp){
+		>$msgfile.tmp {
+			echo -n '# tag:' $tag
+			if(! ~ $#before 0)
+				echo -n ' before:' $before
+			if(! ~ $#after 0)
+				echo -n ' after:' $after
+			echo ''
+			echo $data
+		}
+		edit=1
+	}
+	if(~ $#editor 0)
+		editor=hold
+	$editor $msgfile.tmp
+
+	cleanmsg < $msgfile.tmp > $msgfile
+	if(! test -s $msgfile){
+		echo 'empty task message' >[1=2]
+		exit 'task'
+	}
+}
+
+fn gettag{
+	files=`{ls .pro/todo/}
+	if(! ~ $#change 0)
+		tag=$change
+	if not
+		tag=$#files
+}
+
+fn final{
+	cp $msgfile .pro/todo/$tag
+}
+
+fn sigexit{
+	if(! ~ $#msgfile 0)
+		rm -f $msgfile $msgfile.tmp
+}
+
+flagfmt='c:change change, a:after after, b:before before, e:edit'; args='[msg ...]'
+eval `''{aux/getflags $*} || exec aux/usage
+
+msgfile=/tmp/pro-msg.$pid
+if(! ~ $#* 0){
+	data=`{echo $*}
+if(! ~ $#change 0 )
+	if(test -s .pro/todo/$change){
+		cat .pro/todo/$change > $msgfile.tmp
+		if(! ~ $#data 0)
+			echo $data >> $msgfile.tmp
+	}
+
+@{
+	flag e +
+	gettag
+	editmsg
+	final
+} || echo 'could not write task:' $status >[1=2]
+exit ''
--- a/todo.c
+++ /dev/null
@@ -1,19 +1,0 @@
-#include <u.h>
-#include <libc.h>
-
-#include "pro.h"
-
-static void
-usage(char *argv0)
-{
-	fprint(2, "usage: %s\n", argv0);
-	exits("usage");
-}
-
-void
-main(int argc, char **argv)
-{
-	USED(argc);
-	USED(argv);
-	//walks our zk-backed DAG to find the next task, answers queries, etc
-}