mirror of
https://github.com/tonydamage/nux-env.git
synced 2025-12-11 13:24:28 +01:00
111 lines
2.2 KiB
Text
Executable file
111 lines
2.2 KiB
Text
Executable file
#!/usr/bin/env nuxr-nuxsh
|
|
|
|
# FIXME: Check for configuration
|
|
|
|
#source ~/.config/nux-env/taskie
|
|
|
|
nux.use nux/fs
|
|
nux.use nux/repl
|
|
|
|
nux.use taskie/common
|
|
nux.use taskie/backend.github
|
|
nux.use taskie/backend.gogs
|
|
nux.use taskie/backend.dir
|
|
|
|
function with.backend backendId {
|
|
backend=$(echo $backendId | cut -d: -f1);
|
|
nux.exec.optional backend.$backend.with;
|
|
}
|
|
|
|
function endwith.backend {
|
|
unset backendId;
|
|
unset backendEngine;
|
|
}
|
|
|
|
|
|
|
|
@command labels {
|
|
with.backend $(backend.detect);
|
|
backend.$backend.labels "$@";
|
|
endwith.backend;
|
|
}
|
|
|
|
##
|
|
## add:: [labels] title
|
|
## Adds issue to the task repository. If issue of same title is
|
|
## already known locally this fails.
|
|
##
|
|
@command add {
|
|
with.backend $(backend.detect);
|
|
if ! backend.$backend.issue.exists "$@" ; then
|
|
local labels=$(backend.$backend.labels.id)
|
|
nux.log debug "Labels: $labels"
|
|
label=$(echo "$labels" | grep -G "^$1:")
|
|
local labelName=""
|
|
local labelId=""
|
|
if [ -n "$label" ] ;then
|
|
labelId=${label#*:}
|
|
labelName=${label%:*}
|
|
nux.log debug "First argument is label $labelName ($labelId)"
|
|
shift;
|
|
fi
|
|
|
|
backend.$backend.issue.add "$@";
|
|
else
|
|
nux.echo.error Issue already exists.
|
|
fi
|
|
endwith.backend;
|
|
}
|
|
|
|
nuxr.repl.expose cd pwd ls clear
|
|
|
|
function nuxr.repl.prompt {
|
|
echo "${nc_green}$NUX_SCRIPTNAME${nc_end}:${nc_blue}$(pwd)${nc_end}> "
|
|
}
|
|
|
|
##
|
|
##
|
|
##
|
|
@command list {
|
|
with.backend $(backend.detect);
|
|
backend.$backend.issue.list "$@";
|
|
endwith.backend;
|
|
}
|
|
|
|
taskie_backends=$(nux.cfg.read backends.preference);
|
|
|
|
function 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
|
|
}
|
|
|
|
@command detect {
|
|
backend.detect --all "$@";
|
|
}
|
|
|
|
function 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;
|
|
}
|
|
|
|
function gogs.config.site {
|
|
nux.cfg.read "gogs.\"$1\"$2";
|
|
}
|
|
|
|
function backend.file.detect {
|
|
:
|
|
}
|