~emersion/hut-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch

[PATCH] pages publish: accept archive from stdin

Details
Message ID
<20220513103642.98448-1-colin@urandom.co.uk>
DKIM signature
pass
Download raw message
Patch: +13 -10
There are a number of cases where being able to pass a zipball to hut is
pretty useful. As such, if no archive is provided, we assume that it
will be provided via stdin.
---
 pages.go | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/pages.go b/pages.go
index a9c5473..dfde492 100644
--- a/pages.go
+++ b/pages.go
@@ -30,8 +30,6 @@ func newPagesPublishCommand() *cobra.Command {
	run := func(cmd *cobra.Command, args []string) {
		ctx := cmd.Context()

		filename := args[0]

		if domain == "" {
			log.Fatal("enter a domain with --domain")
		}
@@ -48,13 +46,18 @@ func newPagesPublishCommand() *cobra.Command {

		c := createClient("pages", cmd)

		f, err := os.Open(filename)
		if err != nil {
			log.Fatalf("failed to open input file: %v", err)
		}
		defer f.Close()
		file := gqlclient.Upload{Body: os.Stdin, Filename: "."}
		if len(args) == 1 {
			filename := args[0]

		file := gqlclient.Upload{Body: f, Filename: filepath.Base(filename)}
			f, err := os.Open(filename)
			if err != nil {
				log.Fatalf("failed to open input file: %v", err)
			}
			defer f.Close()

			file = gqlclient.Upload{Body: f, Filename: filepath.Base(filename)}
		}

		site, err := pagessrht.Publish(c.Client, ctx, domain, file, pagesProtocol, subdirectory, siteConfig)
		if err != nil {
@@ -65,9 +68,9 @@ func newPagesPublishCommand() *cobra.Command {
	}

	cmd := &cobra.Command{
		Use:   "publish <archive>",
		Use:   "publish [<archive>]",
		Short: "Publish a website",
		Args:  cobra.ExactArgs(1),
		Args:  cobra.MaximumNArgs(1),
		Run:   run,
	}
	cmd.Flags().StringVarP(&domain, "domain", "d", "", "domain name")
-- 
2.36.1
Reply to thread Export thread (mbox)