Closed iilyak closed 6 years ago
Can you give me some more information on what the end goal should be.
It looks like you're trying to do something based on a list of projects? Not 100% sure, but this might be solved by the for loop. Perhaps not, either way let me know what youre trying to get out and I"d be happy to take a peek.
I wanted to implement a notes taking feature for GTD workflow. I wanted to write alfred new <note-file-name>
which would trigger the workflow as follows.
projects/<project>/<note-file-name>.md
project.tepmplate
task would ask for template to use. The list of templates is list of files in projects/<project>/templates
directory.This workflow is working but I have to construct the full path everywhere. I cannot construct it in project
task. I was thinking to implement internal strings.trim
task and solve the problem as:
project:
command: alfred string.trim $(ls projects | bin/peco --prompt "project>")
register: project
string.trim:
command: echo {{ index .Args 0 | trim }}
However generic string
helper wouldn't work because:
<project>
and <file_path>
. So I would end up with a bunch of private helper tasks.
05:01 PM ✔ kcmerrill tmp ] tree projects/
projects/
└── myprojectfolder
└── my.cool.note
1 directory, 1 file
05:02 PM ✔ kcmerrill tmp ] cat alfred.yml
note:
summary: Add a new note
usage: alfred note <note.name>
exit: 42
commands: |
PF=$(echo "myprojectfolder") # I'm cheating here, but I'm assuming peco simply returns a string? if not let me know.
echo $PF
mkdir -p "/tmp/projects/${PF}"
vim "/tmp/projects/${PF}/{{ index .Args 0 }}"
05:02 PM ✔ kcmerrill tmp ]```
Another thing ...
I'd simply pass .Args 0
throughout all of my tasks, no need to register it IMO.
So just assume all of your tasks, the first argument takes the filename, so task({{ index .Args 0 }}, other stuff, etc, etc)
Thank you for the explanation I'll figure something out.
Thank you for adding support for multiple variables for register
.
👍
I am trying to refactor my draft of a pipeline to use DRY principle. It turns out to be quite hard. How hard it would be to support the following?
Notice two things:
file_name
project
within same taskThe
new
task could be improved as well (maybe):