about summary refs log tree commit diff
path: root/pkgs/development/tools/faas-cli
diff options
context:
space:
mode:
authorsuperherointj <5861043+superherointj@users.noreply.github.com>2022-09-21 18:41:23 -0300
committersuperherointj <5861043+superherointj@users.noreply.github.com>2022-09-22 08:43:16 -0300
commit7ab32908ccd7c62db86f919f4cb0f08577a68985 (patch)
treef5da3587b79fa924ec95b3cf73eee501c3e7806c /pkgs/development/tools/faas-cli
parent55eb08677944821cb5b992e906c0cbecbe027bcc (diff)
faas-cli: add shell completion and version test
Diffstat (limited to 'pkgs/development/tools/faas-cli')
-rw-r--r--pkgs/development/tools/faas-cli/default.nix20
1 files changed, 16 insertions, 4 deletions
diff --git a/pkgs/development/tools/faas-cli/default.nix b/pkgs/development/tools/faas-cli/default.nix
index 0791bff176757..e5b1c05ea6dce 100644
--- a/pkgs/development/tools/faas-cli/default.nix
+++ b/pkgs/development/tools/faas-cli/default.nix
@@ -4,6 +4,9 @@
 , fetchFromGitHub
 , makeWrapper
 , git
+, installShellFiles
+, testers
+, faas-cli
 }:
 let
   faasPlatform = platform:
@@ -24,12 +27,10 @@ buildGoModule rec {
     sha256 = "sha256-iUS8bhTZc7oy7qy0ydmbVW3BNa/lZ2Q+kYefBKrNRyc=";
   };
 
-  nativeBuildInputs = [ makeWrapper ];
+  vendorSha256 = null;
 
   CGO_ENABLED = 0;
 
-  vendorSha256 = null;
-
   subPackages = [ "." ];
 
   ldflags = [
@@ -39,14 +40,25 @@ buildGoModule rec {
     "-X github.com/openfaas/faas-cli/commands.Platform=${faasPlatform stdenv.targetPlatform}"
   ];
 
+  nativeBuildInputs = [ makeWrapper installShellFiles ];
+
   postInstall = ''
     wrapProgram "$out/bin/faas-cli" \
       --prefix PATH : ${lib.makeBinPath [ git ]}
+
+    installShellCompletion --cmd metal \
+      --bash <($out/bin/faas-cli completion --shell bash) \
+      --zsh <($out/bin/faas-cli completion --shell zsh)
   '';
 
+  passthru.tests.version = testers.testVersion {
+    command = "${faas-cli}/bin/faas-cli version --short-version --warn-update=false";
+    package = faas-cli;
+  };
+
   meta = with lib; {
-    homepage = "https://github.com/openfaas/faas-cli";
     description = "Official CLI for OpenFaaS ";
+    homepage = "https://github.com/openfaas/faas-cli";
     license = licenses.mit;
     maintainers = with maintainers; [ welteki techknowlogick ];
   };