mirror of
https://github.com/tonydamage/nux-env.git
synced 2025-12-11 13:24:28 +01:00
Added color support to taskie.
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
This commit is contained in:
parent
73f634318f
commit
7a53e76d85
3 changed files with 64 additions and 2 deletions
|
|
@ -1,11 +1,24 @@
|
|||
nux.use taskie/backend.utils
|
||||
|
||||
nux.use nux.json
|
||||
backend.gogs.list() {
|
||||
local api="$gogs_api_url/repos/$gogs_repository/issues?token=$gogs_api_token"
|
||||
local append_next="&token=$gogs_api_token"
|
||||
|
||||
backend.githublike.get "$api" "$append_next" \
|
||||
| jq -r ".[] | [.number,.state,.title] | @sh"
|
||||
| jq -r ".[] | [.number,.state,(\"#\" + .labels[].name) ,.title] | @sh" \
|
||||
| while read line
|
||||
do
|
||||
eval taskie.issue.display.short $line
|
||||
done
|
||||
}
|
||||
|
||||
argz() {
|
||||
int=0;
|
||||
for arg in "$@"
|
||||
do
|
||||
let int=int+1
|
||||
echo $int $arg
|
||||
done
|
||||
}
|
||||
|
||||
backend.gogs.issue.exists() {
|
||||
|
|
|
|||
48
inc/taskie/common.inc.sh
Normal file
48
inc/taskie/common.inc.sh
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
|
||||
taskie.issue.display.short() {
|
||||
local id="$1";
|
||||
local state="$2";
|
||||
shift;
|
||||
shift;
|
||||
echo -n "$id ";
|
||||
taskie.state.colorized "$state" " ";
|
||||
for arg in "$@"
|
||||
do
|
||||
local before="";
|
||||
local after="";
|
||||
if [[ "$arg" =~ "#" ]]; then
|
||||
taskie.label.colorized "$arg" " "
|
||||
else
|
||||
echo -n "$arg"
|
||||
fi
|
||||
done
|
||||
echo
|
||||
}
|
||||
|
||||
taskie.colorized() {
|
||||
local color_path="$1"
|
||||
local message="$2"
|
||||
local afterMessage="$3"
|
||||
local before=""
|
||||
local after=""
|
||||
color=$(nux.cfg.read colors.$color_path)
|
||||
if [ -n "$color" ]; then
|
||||
color_var="nc_$color"
|
||||
if [ -n "${!color_var}" ]; then
|
||||
before=${!color_var}
|
||||
after=$nc_end
|
||||
fi
|
||||
fi
|
||||
echo -n "${before}${message}${after}${afterMessage}"
|
||||
}
|
||||
|
||||
taskie.state.colorized() {
|
||||
taskie.colorized state.$1 "$1" "$2"
|
||||
}
|
||||
|
||||
taskie.label.colorized() {
|
||||
local label=${1#"#"}
|
||||
taskie.colorized labels.$label "$1" "$2"
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue