From patchwork Thu Oct 13 01:02:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthew James Kraai X-Patchwork-Id: 43356 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9FB9727BBE9; Thu, 13 Oct 2022 02:03:29 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 14DE127BBEA for ; Thu, 13 Oct 2022 02:03:28 +0100 (BST) Received: from localhost ([::1]:39998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oimdC-0002Tb-1z for patchwork@mira.cbaines.net; Wed, 12 Oct 2022 21:03:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50580) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oimco-0002TO-MW for guix-patches@gnu.org; Wed, 12 Oct 2022 21:03:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:59554) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oimco-0000Hq-Dk for guix-patches@gnu.org; Wed, 12 Oct 2022 21:03:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oimcn-00071O-TF for guix-patches@gnu.org; Wed, 12 Oct 2022 21:03:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58408] [PATCH] gnu: Add doctl. Resent-From: Matthew James Kraai Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 13 Oct 2022 01:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58408 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: "(" Cc: 58408@debbugs.gnu.org Received: via spool by 58408-submit@debbugs.gnu.org id=B58408.166562297826980 (code B ref 58408); Thu, 13 Oct 2022 01:03:01 +0000 Received: (at 58408) by debbugs.gnu.org; 13 Oct 2022 01:02:58 +0000 Received: from localhost ([127.0.0.1]:58632 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oimcj-000716-MZ for submit@debbugs.gnu.org; Wed, 12 Oct 2022 21:02:58 -0400 Received: from mail.ftbfs.org ([52.8.68.13]:27668 helo=aws.ftbfs.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oimch-00070s-Lx for 58408@debbugs.gnu.org; Wed, 12 Oct 2022 21:02:56 -0400 Received: from ip68-4-255-43.oc.oc.cox.net ([68.4.255.43] helo=carlo) by aws.ftbfs.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oimca-000DrA-IW; Thu, 13 Oct 2022 01:02:48 +0000 Date: Wed, 12 Oct 2022 18:02:45 -0700 From: Matthew James Kraai Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hi, On Wed, Oct 12, 2022 at 04:01:32PM +0100, ( wrote: > Hello, > > On Wed Oct 12, 2022 at 2:08 PM BST, Matthew James Kraai wrote: > > Here's an updated patch that installs autocompletion scripts for Bash, fish, and Zsh. > > Nice catch :) > > > + (lambda _ > > + (let ((install-completion > > + (lambda (shell file) > > + (let ((file (string-append #$output file))) > > + (mkdir-p (dirname file)) > > + (with-output-to-file file > > + (lambda _ > > + (invoke (string-append #$output "/bin/doctl") > > + "completion" shell))))))) > > + (install-completion "bash" "/etc/bash_completion.d/doctl") > > + (install-completion "fish" > > + "/etc/fish/completions/doctl.fish") > > + (install-completion "zsh" > > + "/etc/zsh/site-functions/_doctl"))))))) > > I think it might be better to use ``(define (...) ...)'' instead of > ``(let ((... (lambda ...))) ...)'' here. Thanks for the suggestion. How about the following patch? diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm index 13d582403b..bc8b7e9efa 100644 --- a/gnu/packages/admin.scm +++ b/gnu/packages/admin.scm @@ -54,6 +54,7 @@ ;;; Copyright © 2022 Petr Hodina ;;; Copyright © 2022 Andreas Rammhold ;;; Copyright © 2022 ( +;;; Copyright © 2022 Matthew James Kraai ;;; ;;; This file is part of GNU Guix. ;;; @@ -5596,3 +5597,52 @@ (define-public rex several hosts in succession or in parallel. It can also be used to copy a file or files to several hosts.") (license license:gpl3+))) + +(define-public doctl + (package + (name "doctl") + (version "1.83.0") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/digitalocean/doctl") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "1narjmj3npd39gxi42k3h4zjyiaq5lvjv31vaxw8slf9h9sjhjh9")))) + (build-system go-build-system) + (arguments + (list #:import-path "github.com/digitalocean/doctl/cmd/doctl" + #:unpack-path "github.com/digitalocean/doctl" + #:go go-1.19 + #:build-flags + #~(list (string-append "-ldflags=-X github.com/digitalocean/doctl.Label=release" + " -X github.com/digitalocean/doctl.Major=" + (car (string-split #$version #\.)) + " -X github.com/digitalocean/doctl.Minor=" + (cadr (string-split #$version #\.)) + " -X github.com/digitalocean/doctl.Patch=" + (caddr (string-split #$version #\.)))) + #:install-source? #f + #:phases + #~(modify-phases %standard-phases + (add-after 'install 'install-completions + (lambda _ + (define (install-completion shell file) + (let ((file (string-append #$output file))) + (mkdir-p (dirname file)) + (with-output-to-file file + (lambda _ + (invoke (string-append #$output "/bin/doctl") + "completion" shell))))) + (install-completion "bash" "/etc/bash_completion.d/doctl") + (install-completion "fish" + "/etc/fish/completions/doctl.fish") + (install-completion "zsh" + "/etc/zsh/site-functions/_doctl")))))) + (home-page "https://github.com/digitalocean/doctl") + (synopsis "Command line client for DigitalOcean") + (description + "@code{doctl} provides a unified command line interface to the DigitalOcean API.") + (license license:asl2.0)))