Command Line Interface (CLI)


#1

Continuing the discussion from Can I see my todo’s across text files?:

I’ve just published a “1.0” version of FoldingText’s command line tool. It’s a work in progress, needing your feedback. Right now it can do two things:

  1. It can run a node path on some text and return the results.

  2. It can evaluate a javascript function that’s given a node tree created from some text. The API that can be used in this function is described in the “core” API section of the API documentation. IE node, tree, but not editor.

Update Version 1.1.0 now includes default modes and has an option to define your own modes.


FoldingText Extensions Wiki
#2

Fantastic – this is working really well …

(For aliases or search paths, the installation, at least on my system, went to /usr/local/lib/node_modules/foldingtext/bin/ft )


#3

HI, I used these instructions to install npm but I can’t get ft to run.

echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh

My unix is novice level and I am getting when running ./ft filename.md

env: node: No such file or directory

Any ideas ?

Thanks.

Mark


#4

If the full path on which ft has been installed is something like:

/usr/local/lib/node_modules/foldingtext/bin/ft

then ./ft would only find it if your current working directory

(revealed by the pwd command) is actually:

/usr/local/lib/node_modules/foldingtext/bin

(which is not all that probable or desirable)

You either need to add the folder in which the ft CLI tool is installed to your unix search path, or write scripts in which you refer explicitly to the full path, or use a variable assigned to that path.

(see, for example, the use of the $PathToFT variable in this script:
https://github.com/RobTrew/txtquery-tools/blob/master/perspectives.ftplugin/txtquery.sh)


#5

Sorry but the unix is a bit beyond me, maybe I should wait for a UI for node searching when Jesse bring it in!

If I run env it brings up this

SHELL=/bin/bash
TMPDIR=/var/folders/3d/jlj74kf17h93dd82h819jt8m0000gn/T/
Apple_PubSub_Socket_Render=/tmp/launch-OPPC12/Render
TERM_PROGRAM_VERSION=326
TERM_SESSION_ID=35EAF66B-89F1-4D46-8A51-AA7734BC5AD7
USER=markbedish
SSH_AUTH_SOCK=/tmp/launch-vTBrIb/Listeners
__CF_USER_TEXT_ENCODING=0x1F5:0:0
__CHECKFIX1436934=1
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
PWD=/Users/markbedish/local/lib/node_modules/foldingtext/bin
LANG=en_GB.UTF-8
HOME=/Users/markbedish
SHLVL=1
LOGNAME=markbedish
_=/usr/bin/env

The ft executable does exist in there so why can’t I run it from there and drag onto Terminal the path of my FT document ? Is there an easy command I can type to get it working?

./ft "/Users/markbedish/Dropbox/Taskpaper/PROJECT\ FT\ Testing.txt.ft"
env: node: No such file or directory

Thanks.

Mark


#6

Stepping back a bit, what are you aiming to do ?


#7

TTBH not that much, just trying to understand about searching.

Taskpaper used to have a query language and I suppose that has been taken over by nodes. I would like to search a bunch of documents for matching tags and specific text, that sort of thing and perhaps some dates I had though the CLI command was a key into that area, but I have only had FT for 3 days so I need to do some more reading.

BTW, thanks very much for the amazing set of scripts which I have started looking into.


Mark


#8

I also had some trouble getting this to install via npm. I remember it had some dependencies, which didn’t seem to install automatically. I have two machines and I ended up with the ft bin installed in two different locations on both machines because I was just doing a lot of trial and error trying to get it to work. Not sure if this is an NPM issue or something with the ft repo on npm …


#9

Hello Derekvan how did you finally get to install via npm? I am having a hard time.


#10

Hi Jesse,

Where can I find the command line tool for Folding Text?


#11

Once you have installed https://nodejs.org/

you can type

npm install foldingtext

at the Terminal.app command line.

(see https://www.npmjs.com/package/foldingtext)

( I have npm at /usr/local/bin/npm )


#12

@complexpoint 's post should get you there. post again if that doesn’t do it.