Fork me on GitHub
#babashka
<
2021-05-14
>
borkdude09:05:34

Released pod-babashka-aws and sql pods (hsqldb, postgres and mssql) as static linux binaries, also through the pod registry. This should make them suitable to run directly from the registry even in alpine images and other linux distros.

borkdude10:05:21

Small demo of bb in Alpine image with hsqldb pod baked in:

FROM alpine:3.7

RUN apk add --no-cache curl

RUN curl -sLO 

RUN tar -xzvf babashka-0.4.1-linux-amd64-static.tar.gz

RUN ./bb -e "(babashka.pods/load-pod 'org.babashka/hsqldb \"0.0.6\")"

ENTRYPOINT ["./bb"]

👍 2
borkdude10:05:05

$ docker run --rm -it f9713317a1a8ba02960741660467feba187107992af07c03f80d3277baf15bed
Babashka v0.4.1 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (require '[babashka.pods :as pods])
nil
user=> (pods/load-pod 'org.babashka/hsqldb "0.0.6")
#:pod{:id "pod.babashka.hsqldb"}

borkdude13:05:21

I'll try it

awesome 1
borkdude13:05:15

Nice! It worked for me when adding this to .zshrc:

autoload -Uz compinit
compinit
echo "hello"
_bb_tasks() {
    local matches=(`bb tasks |tail -n +3 |cut -f1 -d ' '`)
    compadd -a matches
    _files # autocomplete filenames as well
}
compdef _bb_tasks bb

awesome 1
borkdude13:05:25

should that also work for bash? I guess bash works a bit different

borkdude13:05:59

it seems zsh can load bash completions as well, so if we can make it work for bash, it also works for zsh?

cldwalker14:05:50

An example bash autocompletion from aws-vault:

_aws-vault_bash_autocomplete() {
    local cur prev opts base
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    opts=$( ${COMP_WORDS[0]} --completion-bash "${COMP_WORDS[@]:1:$COMP_CWORD}" )
    COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
    return 0
}
complete -F _aws-vault_bash_autocomplete -o default aws-vault
You probably don't need all that. I think you only need to fill out COMPREPLY with matches from zsh impl

lread19:05:36

Very cool! Thanks!

Michaël Salihi16:05:35

PR done for Fish shell too 👍 https://github.com/babashka/book/pull/30

function __bb_complete_tasks
  if not test "$__bb_tasks"
    set -g __bb_tasks (bb tasks |tail -n +3 |cut -f1 -d ' ')
  end

  printf "%s\n" $__bb_tasks
end

complete -f -c bb -n '__fish_seen_subcommand_from tasks' -a "(__bb_complete_tasks)" -d 'List tasks'

borkdude17:05:54

Excellent. Can you also sign the contributors agreement by following this? https://github.com/babashka/book/blob/master/CONTRIBUTING.md

borkdude17:05:25

@admin055 Shouldn't it autocomplete upon typing bb<space><TAB> instead of on bb tasks<space><TAB> ?

Michaël Salihi19:05:47

OK, I'll take care of both @borkdude 👍