kcmerrill / alfred Goto Github PK
View Code? Open in Web Editor NEW(v0.2) Even Batman needs a little help. Task runner. Automator. Build system.
License: MIT License
(v0.2) Even Batman needs a little help. Task runner. Automator. Build system.
License: MIT License
Having an install guide for Alfred as part of README.md
would be awesome.
What's the licensing on good old Alferd? At work we can use OSS, but need to know and make sure it has a license.
Thanks
Bob
I am having the following tasks defined:
project:
summary: Select project
command: ls projects | bin/peco --prompt "project>"
register: project
tasks:
edit
edit:
summary: Open given file
command: |
echo {{ index .Vars "project" | trim }}
The error I am getting is
alfred project
[project] Select project (Args: [])
couchdb
---
✔ project DONE
panic: template: translate:1: function "trim" not defined
goroutine 1 [running]:
panic(0x3f4ae0, 0xc8200de570)
/usr/local/go/src/runtime/panic.go:481 +0x3e6
text/template.Must(0x0, 0x79d028, 0xc8200de570, 0x0)
/usr/local/go/src/text/template/helper.go:23 +0x4b
github.com/kcmerrill/alfred/alfred.(*Task).template(0xc8200c9680, 0xc820065200, 0x53, 0x496701, 0x0, 0x0)
/usr/src/app/build/src/github.com/kcmerrill/alfred/alfred/task.go:409 +0x251
github.com/kcmerrill/alfred/alfred.(*Task).Prepare(0xc8200c9680, 0xc82000a300, 0x0, 0x0, 0xc8200dc4e0, 0x0)
/usr/src/app/build/src/github.com/kcmerrill/alfred/alfred/task.go:361 +0x95f
github.com/kcmerrill/alfred/alfred.(*Alfred).runTask(0xc82005b180, 0xc8200de2c8, 0x4, 0xc82000a300, 0x0, 0x0, 0xc8200dce00, 0x1)
/usr/src/app/build/src/github.com/kcmerrill/alfred/alfred/alfred.go:157 +0x4d2
github.com/kcmerrill/alfred/alfred.(*Alfred).runTask(0xc82005b180, 0x7fff5fbff2af, 0x7, 0xc82000a300, 0x0, 0x0, 0x362c00, 0xc82000f7a0)
/usr/src/app/build/src/github.com/kcmerrill/alfred/alfred/alfred.go:300 +0x1a92
github.com/kcmerrill/alfred/alfred.(*Alfred).findTask(0xc82005b180, 0x3ec)
/usr/src/app/build/src/github.com/kcmerrill/alfred/alfred/alfred.go:106 +0x29f
github.com/kcmerrill/alfred/alfred.New(0xc82000a300, 0x2, 0x2)
/usr/src/app/build/src/github.com/kcmerrill/alfred/alfred/alfred.go:68 +0x2d7
main.main()
/usr/src/app/build/src/github.com/kcmerrill/alfred/alfred.go:40 +0x8f2
alfred task(1,2)
would really run task(1,2)
Lets start off first doing them in sync, but we can later add an astric or a ! denoting it can be run in parallel.
Just a simple X or checkmark for failed/succesful tasks would be nice.
It would be splendid for Alfred to have a notion of environment variables, and whether they are set or not.
Our code deals with environment variables a lot, and currently it would mean running the following:
export.var:
summary: Export var into Alfred context
register: my.var
command: |
echo "${VAR}"
test.var:
summary: Tests whether VAR is empty
test: test -n "{{ index .Vars "my.var" }}"
fail: set.default.var
set.default.var:
register: my.var
command: |
echo "My default"
It's more than a little cumbersome, as you might realize.
Something along these lines would help:
my.task:
env:
VAR: "My default"
command: |
echo "${VAR}"
or
my.task:
env:
- VAR
command: |
echo "${VAR}"
and fail if ${VAR}
isn't set.
I could even think you could run other Alfred tasks to fill empty variables:
my.var:
register: my.variable
command: |
echo "derp!"
my.task:
env:
VAR: {{ index .Vars "my.variable" }}
command: |
echo "${VAR}"
What do you think?
Currently elapsed time(overall) gets output when a task gets finished. Would be nice if it were specific to the task too
This might be out of scope for Alfred. However since Alfred got remote workflow feature recently it might be very easy to implement an integrity check for downloads (if you think it is useful).
Ability to download files via http/https with integrity checking. The goal is to automate the installation of development environment for new team members. We would love to be able to specify a list of urls to download with correspondent sha256 hash for every file. Of cause we could use a combination of following tools:
But how to download and check integrity of these tools? It is getting complicated to bootstrap the environment very quickly.
Make it so that you can pass in a git location. Right now alferd only understands github. It would be nice to put modules in GitLab, Bitbucket, and xyz.
With the breaking changes in 0.2, it'd be nice to have an at-a-glance document to understand how to migrate 0.1 -> 0.2.
sometask:
dir: $PWD
echo: "????"
sometask:
dir: {{ .PWD }}
If no arguments are passed in, but there is a default task ... it should be run.
Hi,
Is windows supported? Currently, i am running alfred but not able to see command results
Prerequisite:
summary: Making sure everything is ready
command: |
echo "Checkout this multi line command!"
cd /tmp && pwd
cd /tmp
pwd
Its just giving up following output
[Prerequisite] Making sure everything is ready
Thanks
We should store stdin/stdout to a var to be used later on.
Idea being:
echo "hello world" | alfred taskname
taskname:
command: echo {{ .STDIN }}
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?
new:
summary: Add new item
command: echo {{ index .Args 0 }}
register: file_name
tasks:
project
project.edit
project:
summary: Select project
command: ls projects | bin/peco --prompt "project>"
register:
project: projects/{{ index .Vars "project" | trim }}
file_name: projects/{{ index .Vars "project"}}/{{index .Vars "file_name" | trim}}
Notice two things:
file_name
project
within same taskThe new
task could be improved as well (maybe):
new:
summary: Add new item
command: none
register:
file_name: {{ index .Args 0 | trim }}
tasks:
project
project.edit
It doesn't seem to be away to disable echo in alfred's prompt feature. It always prints the entered data back to terminal. Which makes it not secure to use for things like password.
Alfred is awesome, thanks so much!
I'm following along with the example in manual that shows you how to register a reusable value. When I call alfred forty.two with the below setup I'm getting the error below.
fourty.one:
summary: Register a variable
register: my.new.var
command: |
echo "5678"
fourty.two:
setup: fourty.one
summary: Retrieve a registered variable
command: |
echo The variable is {{ index .Vars "my.new.var"}}
[fourty.one] Register a variable (Args: [])
panic: assignment to entry in nil map
goroutine 1 [running]:
panic(0x733c80, 0xc4200fc6d0)
/usr/local/go/src/runtime/panic.go:500 +0x1a1
github.com/kcmerrill/alfred/alfred.(*Alfred).runTask(0xc4200e1110, 0xc4200fc2d0, 0xa, 0xc420078060, 0x0, 0x0, 0xc420071800, 0x1)
/go/src/github.com/kcmerrill/alfred/alfred/alfred.go:215 +0x186f
github.com/kcmerrill/alfred/alfred.(*Alfred).runTask(0xc4200e1110, 0x7ffcf7f10e87, 0xa, 0xc420078060, 0x0, 0x0, 0x0, 0x0)
/go/src/github.com/kcmerrill/alfred/alfred/alfred.go:143 +0x2b3
github.com/kcmerrill/alfred/alfred.(*Alfred).findTask(0xc4200e1110, 0x68d)
/go/src/github.com/kcmerrill/alfred/alfred/alfred.go:106 +0x46d
github.com/kcmerrill/alfred/alfred.New(0xc420078060, 0x2, 0x2)
/go/src/github.com/kcmerrill/alfred/alfred/alfred.go:68 +0x2ba
main.main()
/go/src/github.com/kcmerrill/alfred/alfred.go:40 +0x1cf
I didn't think it was necessary which is why I didn't add it in to the latest version, but I think we need it.
Not only usage text for each task, but an example.
tdd:
usage: alfred /testing:tdd <reg_expression> <command_to_execute_on_file_change>
example: alfred /testing:tdd ".*?.go$" "echo something here"
I wanted to call remote task from inside alfred.yml
and couldn't find any documentation on how to do it. I am quite sure it was possible but I couldn't recall how.
I tried something like the following
remote:
summary: test
command: alfred https://raw.githubusercontent.com/kcmerrill/alfred-tasks/master//testing.yml:run.go
and
remote:
summary: test
command: alfred https://raw.githubusercontent.com/kcmerrill/alfred-tasks/master//testing.yml run.go
Go through each arg and "clean" them. Removing spaces, periods etc ... only allowing letters/chars. for every task.
Hi @kcmerrill what happend to the RTFM, last week it was still complete..
Currently the repository is hardcoded here.
Which makes it hard for users to add own tasks. Currently the only ways to call remote tasks are:
alfred iilyak/alfred-tasks
- there is no way to select specific yml file
✘ https://raw.githubusercontent.com/iilyak/alfred-tasks/master/alfred.yml`
alfred https://raw.githubusercontent.com/iilyak/alfred-tasks/master//testing.yml
- very longThis problem could be solved either via:
alfred iilyak/alfred-tasks:testing
alfred iilyak:testing
alfred iilyak/myrepo:testing
- most flexible IMOI am trying to build a binary for MacOS from docker container which runs linux. I used to use following commands to build previous versions of alfred.
Start docker container
docker run --rm -it -v "$PWD":/usr/src/app -w /usr/src/app golang bash
Inside docker container run
GOPATH=/usr/src/app/build GOOS=darwin GOARCH=amd64 go get github.com/kcmerrill/alfred
Here is the output I get
# github.com/kcmerrill/alfred/alfred
build/src/github.com/kcmerrill/alfred/alfred/output.go:67: time.Since(context.Started).Round undefined (type time.Duration has no field or method Round)
build/src/github.com/kcmerrill/alfred/alfred/summary.go:18: time.Since(context.Started).Round undefined (type time.Duration has no field or method Round)
build/src/github.com/kcmerrill/alfred/alfred/summary.go:20: time.Since(context.Started).Round undefined (type time.Duration has no field or method Round)
I have go version 1.8.3
# go version
go version go1.8.3 linux/amd64
Could you document which version of go is required?
currently command with a | only exits based on the last run exit code.
We should create commands that allows the use for | but if any of them fail, then it would exit properly.
I would like to register a variable which is a transformation of user's input. I can register ENV, but registering regular variable doesn't work as I would expect.
The following works:
test1:
summary: test
prompt:
foo: foo?
env:
FOO: echo {{ .Vars.foo | dir }}
command:
echo $FOO
it outputs the following
11:20 $ bin/alfred test1
[ 0s] (13 Apr 18 11:20 PDT) test1 started [] test
[ 0s] (13 Apr 18 11:20 PDT) test1 prompt foo?
bar/baz/foo
[ 8s] (13 Apr 18 11:20 PDT) test1 registered foo bar/baz/foo
[ 8s] (13 Apr 18 11:20 PDT) test1 set $FOO bar/baz
[ 8s] (13 Apr 18 11:20 PDT) bar/baz
[ 8s] (13 Apr 18 11:20 PDT) test1 ✔ ok [] elapsed time '8s'
However following doesn't work
test2:
summary: test2
prompt:
foo_raw: foo?
register:
foo: echo {{ .Vars.foo_raw | dir }}
command:
echo {{ .Vars.foo }}
outputs
bin/alfred test2
[ 0s] (13 Apr 18 11:21 PDT) test2 template Invalid Argument(s)
Not sure if this is a feature for alfred, or another standalone app, but regardless I'd like to document it here.
@iilyak had an idea regarding data manipulation for various data types(json, csv, yaml).
Some of these alfred files are rather large. We should be able to split them up by various methods.
1.) grab alfred.yml files in a given directory
2.) grab .alfred/.yml files
3.) grab alfred/*yml files
Add checkpoints. That way if the checkpoint exists, you can skip the task. Something like:
taskname:
summary: Some task that gets run
command: |
echo "hello world"
checkpoint: daily|hourly|golangdur(1h|9m|1h9,)
I am testing the setup
functionality in context of #53 (comment).
Here is my minimal alfred.yml
file
ensure.ssh.keys:
summary: Check that ssh keys exist
command: test -f non_existent_file
private: true
test:
summary: Should fail due to setup
setup: |
ensure.ssh.keys
command: >
echo SUCCESS
Here is the output:
build/bin/darwin_amd64/alfred test
[ 0s] (27 Dec 17 14:10 PST) test started [] Should fail due to setup
[ 0s] (27 Dec 17 14:10 PST) test setup ensure.ssh.keys
[ 0s] (27 Dec 17 14:10 PST) ensure.ssh.keys started [] Check that ssh keys exist
[ 0s] (27 Dec 17 14:10 PST) ensure.ssh.keys command failed
[ 0s] (27 Dec 17 14:10 PST) ensure.ssh.keys ✘ failed [] elapsed time '0s'
[ 0s] (27 Dec 17 14:10 PST) SUCCESS
[ 0s] (27 Dec 17 14:10 PST) test ✔ ok [] elapsed time '0s'
Should be able to run alfred tasks with multiple params.
Example:
task.name:
tasks: task(1, 2)
multitasks: task(1,3)
That way we don't need to create multiple tasks that do the same thing but with different params
Alfred is an awesome. Thank you for developing it.
I am very excited about opportunities which the tool provides and looking forward to use it for various things. I hope it is ok to share my scenarios with you just in case you find it helpful for yourself and implement something similar eventually. I am sorry for the long post and list of features. I clearly understand that it is an open source project and most of the features wouldn't be implemented due to lack of time. However I wanted to share just to brainstorm some ideas.
There are so many tools which do something very similar. Finally I think I found the one which I could use for my tasks (Alfred). The list of somewhat similar tools:
I was looking for a tool which
for file_path in sys.stdin:
extract meta data from jpg
move and rename files
generate html pages where files are sorted by `aperture value` or by `iso`
sometimes send error(file_path, some_error) # send errors back to alfread
Currently, every request for custom modules etc are sent to the web.
We should download the contents each time, and if unable to find we should take a look in ~/.alfred/offline/modulename/alfred.yml
This is important because sometimes you might not want default all arguments
OR
If we default to a blank string, false, etc etc ... then lets consider it a bunk default value. <-- i like this one better
something:
retry: 3
command: ls /idonotexist
^^^ should retry 3 times before continuing on
According to the example in documentation of serve command it binds to 0.0.0.0:. Is it possible to specify exact interface to bind on. I would like this web server to be only available on 127.0.0.1.
When setting variables, or registering variables, have the ability to store them for long term usage. This could be useful for things like incrementing build numbers, version numbers etc ...
Can be stored in boltdb, yml, json etc ...
New version removes test/fail/ok. Is there any replacement?
I was looking for a way to enter strings interactively and pass the entered value to another task. Unfortunately I couldn't find a cross platform (linux/mac/win32) cli tool which would read something from keyboard (password) and echo it to stdout so I can register it in a variable. The closest thing I found is https://github.com/quininer/ttyaskpass. However sometimes the input is not the pass so it wouldn't really work. What would be your suggestion?
First off all. Thanks for open sourcing this tool! This is very similiar to something I wanted to build since quite some time!
One thing I'm wondering about is the return value for multiple tasks
Currently it looks like of I have a task that calls other tasks via multitask (or tasks) and one of those tasks faisl, then
ok still evaluates to true.
E.g.
for
speak:
multitask: say.hello say.howareyou
ok: ok
if for example say.howareyou fails. it will still call the ok task.
as far as I understand the reason is that the ok task is run because the (empty) command for speak worked fine.
Is there a way to run something based on the result of the multitask?
:
We have remote modules ... but it would be nice to have plugins.
Basically a way to download/install and extend the functionality without actually updating alfred's core code.
I would love to be able to run a task within Alfred and capture the output of said task inside a variable or parameter which I can then pass to another task.
Example pseudo-code:
variable:
summary: Gets a random number
command: $(($RANDOM%10500+10122))
print.random.number:
summary: Output of a random number
command: echo "The number is {{ .variable.Output }}"
Hi @kcmerrill do you also have nice trick to chain tasks
And so that the output of task.one becomes the input of task.two
I could amagine something like:
tasks: task.one | task.two
Needs to be put in the manual.
When searching for modules, "private" should be searched locally.
~/.alfred/private/module/alfred.yml
Would be awesome to have a web presence where people could submit/search modules instead of relying on github and this code base to update common modules
Alfred is a great tool. Thank you for developing it.
This is not an issue but a feature request
It would be really nice to add automatic parsing of an output of a job and store the parsed groups in the variables.
The idea is inspired by filebit
With this feature it would be possible to specify something like (using logstash grok):
node.ps:
summary: Return list of processes on remote node
register: node.ps
command: |
ssh {{ index .Args 0 }} ps -elf
ok: node.ps.ok
fail: node.ps.fail
grok:
ssh_error: "ssh: (?<ERROR>[^\,]*)"
process: "%{F} %{S} %{UID} %{PID} %{PPID} %{C} %{PRI} %{NI} %{ADDR} %{SZ} %{WCHAN STIME} %{TTY} %{TIME} %{CMD}"
node.ps.ok:
register: node.ps.ok
command:
echo '{{ index .Vars "node.ps[*][CMD]" }}' ### <<--- NOT sure about exact syntax here
private: true
node.ps.fail:
tasks: node.ping
There are plenty logstash grok patterns here
https://github.com/logstash-plugins/logstash-patterns-core/blob/master/patterns/
There are few grok engines written in go already.
If the alfred files get large, you an simply * next to the task name and make it stand out more when doing "alfred" by itself.
Lets create a "test" key.
We can tackle this many different ways(open to suggestions) but this would allow each task to test for something before continuing.
Depending on exit code would be then transferred to ok/fail tasks ...
A few ideas:
test: dir.exists whatever
test: dir.older 15m
test: dir.newer 15m
test: app.exists wget
etc etc ...
I've been notating my tasks with periods.
docker.push.whatever.latest
docker.push.whatever2.latest
docker.push.whatever.canary
docker.push.whatever2.canary
Would be interesting to do something like:
docker.push.*.latest
or docker.push.*
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.