lol

tcld: init at 0.40.0

authored by

jkachmar and committed by
Jade Lovelace
62124208 81dcc773

+117
+33
pkgs/by-name/tc/tcld/bash_autocomplete
···
··· 1 + #! /bin/bash 2 + # based on https://github.com/urfave/cli/blob/v2.27.6/autocomplete/bash_autocomplete 3 + 4 + # Macs have bash3 for which the bash-completion package doesn't include 5 + # _init_completion. This is a minimal version of that function. 6 + _cli_init_completion() { 7 + COMPREPLY=() 8 + _get_comp_words_by_ref "$@" cur prev words cword 9 + } 10 + 11 + _cli_bash_autocomplete() { 12 + if [[ "${COMP_WORDS[0]}" != "source" ]]; then 13 + local cur opts base words 14 + COMPREPLY=() 15 + cur="${COMP_WORDS[COMP_CWORD]}" 16 + if declare -F _init_completion >/dev/null 2>&1; then 17 + _init_completion -n "=:" || return 18 + else 19 + _cli_init_completion -n "=:" || return 20 + fi 21 + words=("${words[@]:0:$cword}") 22 + if [[ "$cur" == "-"* ]]; then 23 + requestComp="${words[*]} ${cur} --generate-bash-completion" 24 + else 25 + requestComp="${words[*]} --generate-bash-completion" 26 + fi 27 + opts=$(eval "${requestComp}" 2>/dev/null) 28 + COMPREPLY=($(compgen -W "${opts}" -- ${cur})) 29 + return 0 30 + fi 31 + } 32 + 33 + complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete tcld
+15
pkgs/by-name/tc/tcld/compgen.patch
···
··· 1 + diff --git a/app/app.go b/app/app.go 2 + index 57a9b36fdb..96acf94dc1 100644 3 + --- a/app/app.go 4 + +++ b/app/app.go 5 + @@ -28,6 +28,7 @@ 6 + EnableDebugLogsFlag, 7 + }, 8 + Commands: params.Commands, 9 + + EnableBashCompletion: true, 10 + } 11 + 12 + return app, nil 13 + diff --git a/compgen.patch b/compgen.patch 14 + new file mode 100644 15 + index 0000000000..e69de29bb2
+47
pkgs/by-name/tc/tcld/package.nix
···
··· 1 + { 2 + buildGoModule, 3 + fetchFromGitHub, 4 + lib, 5 + stdenvNoCC, 6 + installShellFiles, 7 + nix-update-script, 8 + ... 9 + }: 10 + 11 + buildGoModule (finalAttrs: { 12 + pname = "tcld"; 13 + version = "0.40.0"; 14 + src = fetchFromGitHub { 15 + owner = "temporalio"; 16 + repo = "tcld"; 17 + rev = "refs/tags/v${finalAttrs.version}"; 18 + hash = "sha256-bIJSvop1T3yiLs/LTgFxIMmObfkVfvvnONyY4Bsjj8g="; 19 + }; 20 + vendorHash = "sha256-GOko8nboj7eN4W84dqP3yLD6jK7GA0bANV0Tj+1GpgY="; 21 + ldFlags = [ 22 + "-s" 23 + "-w" 24 + ]; 25 + 26 + # FIXME: Remove after https://github.com/temporalio/tcld/pull/447 lands. 27 + patches = [ ./compgen.patch ]; 28 + 29 + # NOTE: Some tests appear to require (local only?) network access, which 30 + # doesn't work in the sandbox. 31 + __darwinAllowLocalNetworking = true; 32 + 33 + nativeBuildInputs = [ installShellFiles ]; 34 + postInstall = lib.optionalString (stdenvNoCC.buildPlatform.canExecute stdenvNoCC.hostPlatform) '' 35 + installShellCompletion --cmd tcld --bash ${./bash_autocomplete} 36 + installShellCompletion --cmd tcld --zsh ${./zsh_autocomplete} 37 + ''; 38 + 39 + passthru.updateScript = nix-update-script { }; 40 + 41 + meta = { 42 + description = "The temporal cloud cli."; 43 + homepage = "https://www.github.com/temporalio/tcld"; 44 + license = lib.licenses.mit; 45 + teams = [ lib.teams.mercury ]; 46 + }; 47 + })
+22
pkgs/by-name/tc/tcld/zsh_autocomplete
···
··· 1 + #compdef $PROG 2 + 3 + ## based on https://github.com/urfave/cli/blob/v2.27.6/autocomplete/zsh_autocomplete 4 + 5 + _cli_zsh_autocomplete() { 6 + local -a opts 7 + local cur 8 + cur=${words[-1]} 9 + if [[ "$cur" == "-"* ]]; then 10 + opts=("${(@f)$(${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}") 11 + else 12 + opts=("${(@f)$(${words[@]:0:#words[@]-1} --generate-bash-completion)}") 13 + fi 14 + 15 + if [[ "${opts[1]}" != "" ]]; then 16 + _describe 'values' opts 17 + else 18 + _files 19 + fi 20 + } 21 + 22 + compdef _cli_zsh_autocomplete tcld