blob: b872ea694b53ee32d21e5a6190385ec7c13b4ae1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
{
lib,
stdenv,
buildGoModule,
fetchFromGitHub,
makeWrapper,
installShellFiles,
go,
}:
buildGoModule (finalAttrs: {
pname = "cobra-cli";
version = "1.3.0";
src = fetchFromGitHub {
owner = "spf13";
repo = "cobra-cli";
rev = "v${finalAttrs.version}";
sha256 = "sha256-E0I/Pxw4biOv7aGVzGlQOFXnxkc+zZaEoX1JmyMh6UE=";
};
vendorHash = "sha256-vrtGPQzY+NImOGaSxV+Dvch+GNPfL9XfY4lfCHTGXwY=";
nativeBuildInputs = [
makeWrapper
installShellFiles
];
allowGoReference = true;
postPatch = ''
substituteInPlace "cmd/add_test.go" \
--replace "TestGoldenAddCmd" "SkipGoldenAddCmd"
substituteInPlace "cmd/init_test.go" \
--replace "TestGoldenInitCmd" "SkipGoldenInitCmd"
'';
postFixup = ''
wrapProgram "$out/bin/cobra-cli" \
--prefix PATH : ${go}/bin
'';
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
installShellCompletion --cmd cobra-cli \
--bash <($out/bin/cobra-cli completion bash) \
--fish <($out/bin/cobra-cli completion fish) \
--zsh <($out/bin/cobra-cli completion zsh) \
# Ironically, cobra-cli still uses old, slightly buggy completion code
# This will correct the #compdef tag and add separate compdef line
# allowing direct sourcing to also activate the completion
substituteInPlace "$out/share/zsh/site-functions/_cobra-cli" \
--replace-fail '#compdef _cobra-cli cobra-cli' "#compdef cobra-cli''\ncompdef _cobra-cli cobra-cli"
'';
meta = {
description = "Cobra CLI tool to generate applications and commands";
mainProgram = "cobra-cli";
homepage = "https://github.com/spf13/cobra-cli/";
changelog = "https://github.com/spf13/cobra-cli/releases/tag/v${finalAttrs.version}";
license = lib.licenses.afl20;
maintainers = [ lib.maintainers.ivankovnatsky ];
};
})
|