CLI: create or modify tiddler

21 views
Skip to first unread message

FND

unread,
Apr 20, 2013, 5:14:01 AM4/20/13
to tidd...@googlegroups.com
I'm currently writing a command-line script to populate tiddlers:

$ note journal "hello world"

That should either create a tiddler "hello world" in the "journal" bag
or, if present, pipe a representation of the existing tiddler into my
text editor for modification.

AFAIK twanager doesn't let me retrieve tiddlers (yet?), so the only
reasonable options appear to be
* accessing the Python API
* using the HTTP API to check whether the tiddler exists and retrieving
its text representation, then using `twanager tiddler` to create or
modify the tiddler

Neither of those options seem very appealing - is there perhaps
something I'm missing?


-- F.


PS: The ultimate goal is to create a non-browser client for my personal
workflow(s). (Yes, I'm familiar with twikrad, but never quite got
comfortable with it.)

chris...@gmail.com

unread,
Apr 20, 2013, 2:23:25 PM4/20/13
to tidd...@googlegroups.com
On Sat, 20 Apr 2013, FND wrote:

> AFAIK twanager doesn't let me retrieve tiddlers (yet?), so the only
> reasonable options appear to be
> * accessing the Python API
> * using the HTTP API to check whether the tiddler exists and retrieving
> its text representation, then using `twanager tiddler` to create or
> modify the tiddler

I'm a bit confused here. You seem to be saying "I don't want to use
either of the two very mature and very flexible APIs that are provided
by TiddlyWeb".

I'm guessing however that what you really mean though is: I want to
integrate a simple tool (that preferably already exists) into a stack
of unix tools in a shell script to accomplish the task above.

Which comes out making a bit more sense...

And you're right, if you don't want to engage Python and you don't
want to go over HTTP, the option's not there.

So the question, for me, becomes: How come using HTTP doesn't appeal?
GETting and PUTting (with curl) the text representation of a tiddler
seems a good fit here and means you don't have to be local to the
machine with the tiddlyweb store.

But: There is some awkwardness in the fact that you can't cat a
tiddler. Given your predilections if might sense for you take this
plugin which never quite got off the ground:

https://github.com/tiddlyweb/tiddlyweb-plugins/blob/master/unixcom/unixcom.py

And add cat, or something with a similar sort of name. cp, mv,
rm, touch and ls are there already (unclear if they still work but
they did once upon a time).

And turn it into a real plugin and put it on pypi.

You'll probably want to change how erroring out happens (right now it
prints a warning and then goes to usage(), a sys.exit(1) would be more
appropriate).

Or just use HTTP.

> PS: The ultimate goal is to create a non-browser client for my personal
> workflow(s). (Yes, I'm familiar with twikrad, but never quite got
> comfortable with it.)

twikrad is really useful if you are in the habit of generating long
content for and with other people but I too have found it sort of
wrong somehow for my own personal use (which is why there is now an
@edit). I presume this is because of context switching issues: the
environment in which the original wikrad was being used it was
generally used at a point when someone said "and now I will write
something" or "and now I will do some hard core gardening". That is:
there was an intentional and important switching of context.

--
Chris Dent http://burningchrome.com/
[...]

FND

unread,
Apr 21, 2013, 4:20:43 AM4/21/13
to tidd...@googlegroups.com
> I'm a bit confused here. You seem to be saying "I don't want to use
> either of the two very mature and very flexible APIs that are provided
> by TiddlyWeb".

Pretty much; as you've concluded, what I was hoping for was a Unix CLI
API[1] - unixcom[2] appears to fit the bill, so I'll look into that.

> the question, for me, becomes: How come using HTTP doesn't appeal?
> GETting and PUTting (with curl) the text representation of a tiddler
> seems a good fit here and means you don't have to be local to the
> machine with the tiddlyweb store.

I'd been pondering this even before you asked the question. While
accessing the HTTP API is certainly an option, it doesn't feel entirely
natural in the Unix CLI context.

For example, entity names have to be escaped - while that's not much of
an issue (I currently use tiddlyweb.web.util:encode_name in a Python
one-liner), it's something that needs to be considered and doesn't feel,
well, unmediated the way `twanager bag` or `twanager tiddler` do.

So yeah, extending twanager seems like the way to go for me. (There's
some irony here, since I might as well write the client in Python
instead of writing a layer to provide the API for the client - but irony
is what we live for around here... )

> twikrad is really useful if you are in the habit of generating long
> content for and with other people [...] I presume this is because of
> context switching issues

I guess I lack the context/experience to make much sense of this.


-- F.


[1] as you might have noticed with tagdex, I like to have functionality
available both via HTTP and on the command line
[2] yet another thing in the vast universe of TiddlyWeb extensions which
had escaped my memory
Reply all
Reply to author
Forward
0 new messages