1
1
Fork 0
mirror of https://github.com/tonydamage/nux-env.git synced 2025-12-11 13:24:28 +01:00
nux-env/bin/taskie
Tony Tkacik bc350810b7 taskie: Added pwd, ls, cd REPL commands.
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
2017-06-21 16:04:10 +02:00

113 lines
1.8 KiB
Text
Executable file

#!/usr/bin/env nux-runner
# FIXME: Check for configuration
#source ~/.config/nux-env/taskie
nux.use nuxfs
nux.use nux.repl
nux.use taskie/common
nux.use taskie/backend.github
nux.use taskie/backend.gogs
with.backend() {
backendId="$1";
backend=$(echo $backendId | cut -d: -f1);
nux.exec.optional backend.$backend.with;
}
endwith.backend() {
unset backendId;
unset backendEngine;
}
task.labels() {
:
}
##
## add:: [labels] title
## Adds issue to the task repository. If issue of same title is
## already known locally this fails.
##
task.add() {
with.backend $(backend.detect);
if ! backend.$backend.issue.exists "$@" ; then
backend.$backend.add "$@";
else
nux.echo.error Issue already exists.
fi
endwith.backend;
}
nuxr.repl.expose cd pwd ls
##
##
##
task.list() {
with.backend $(backend.detect);
backend.$backend.list "$@";
endwith.backend;
}
taskie_backends=$(nux.cfg.read backends.preference);
git.origins() {
nux.log debug Closest git parent is $closest_git;
if [ -n "$closest_git" ]; then
grep -E "url *=" "$closest_git/config" | cut -d= -f2
fi
}
task.detect() {
backend.detect --all "$@";
}
backend.detect() {
all=$1;
if [ "$all" = "--all" ]; then
shift;
fi
for backend in $taskie_backends; do
nux.log trace Executing backend $backend detection
localId=$(backend.$backend.detect "$@")
if [ -n "$localId" ]; then
echo $backend:$localId
if [ "$all" != "--all" ]; then
return 0;
fi
fi
done;
}
gogs.config.site() {
nux.cfg.read "gogs.\"$1\"$2";
}
backend.github.detect() {
closest_git=$(nuxfs.closest .git "$1")
git.origins "$closest_git" | grep github.com | while read origin
do
repo=$(nux.url.parse "$origin" "\9")
echo $repo:$closest_git
done
}
backend.file.detect() {
:
}
backend.dir.detect() {
:
}