From 274916711791688b38f275a88f7f58a8c85d6c7e Mon Sep 17 00:00:00 2001 From: zstadler Date: Sun, 1 Dec 2024 13:47:38 +0200 Subject: [PATCH 1/5] Update `pmtiles upload --help` Related to #194 --- main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 85f441c..d7a0e0e 100644 --- a/main.go +++ b/main.go @@ -109,8 +109,8 @@ var cli struct { } `cmd:"" help:"Download a local archive to remote storage." hidden:""` Upload struct { - Input string `arg:"" type:"existingfile"` - Key string `arg:""` + InputPMTiles string `arg:"" type:"existingfile" help:"The local PMTiles file"` + RemotePMTiles string `arg:"" help:"The name for the remote PMTiles source"` MaxConcurrency int `default:"2" help:"# of upload threads"` Bucket string `required:"" help:"Bucket to upload to."` } `cmd:"" help:"Upload a local archive to remote storage."` @@ -203,8 +203,8 @@ func main() { if err != nil { logger.Fatalf("Failed to convert %s, %v", path, err) } - case "upload ": - err := pmtiles.Upload(logger, cli.Upload.Input, cli.Upload.Bucket, cli.Upload.Key, cli.Upload.MaxConcurrency) + case "upload ": + err := pmtiles.Upload(logger, cli.Upload.InputPMTiles, cli.Upload.Bucket, cli.Upload.RemotePMTiles, cli.Upload.MaxConcurrency) if err != nil { logger.Fatalf("Failed to upload file, %v", err) From 40521b2b90fcf5dce36306fef9c826fb91493f76 Mon Sep 17 00:00:00 2001 From: zstadler Date: Sun, 1 Dec 2024 13:52:20 +0200 Subject: [PATCH 2/5] Update main.go --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index d7a0e0e..e11e342 100644 --- a/main.go +++ b/main.go @@ -203,7 +203,7 @@ func main() { if err != nil { logger.Fatalf("Failed to convert %s, %v", path, err) } - case "upload ": + case "upload ": err := pmtiles.Upload(logger, cli.Upload.InputPMTiles, cli.Upload.Bucket, cli.Upload.RemotePMTiles, cli.Upload.MaxConcurrency) if err != nil { From 93927855ecce5140773f790a3e47974965732be4 Mon Sep 17 00:00:00 2001 From: zstadler Date: Sun, 1 Dec 2024 13:59:00 +0200 Subject: [PATCH 3/5] Update upload.go --- pmtiles/upload.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pmtiles/upload.go b/pmtiles/upload.go index 53c52eb..71a18a3 100644 --- a/pmtiles/upload.go +++ b/pmtiles/upload.go @@ -19,7 +19,7 @@ func partSizeBytes(totalSize int64) int { } // Upload a pmtiles archive to a bucket. -func Upload(logger *log.Logger, input string, bucket string, key string, maxConcurrency int) error { +func Upload(logger *log.Logger, inputpmtiles string, bucket string, remotepmtiles string, maxConcurrency int) error { ctx := context.Background() b, err := blob.OpenBucket(ctx, bucket) @@ -28,7 +28,7 @@ func Upload(logger *log.Logger, input string, bucket string, key string, maxConc } defer b.Close() - f, err := os.Open(input) + f, err := os.Open(inputpmtiles) if err != nil { return fmt.Errorf("Failed to open file: %w", err) } @@ -44,7 +44,7 @@ func Upload(logger *log.Logger, input string, bucket string, key string, maxConc MaxConcurrency: maxConcurrency, } - w, err := b.NewWriter(ctx, key, opts) + w, err := b.NewWriter(ctx, remotepmtiles, opts) if err != nil { return fmt.Errorf("Failed to obtain writer: %w", err) } From 81bb40e3c5d4de08172a0486de83625466eec7e0 Mon Sep 17 00:00:00 2001 From: zstadler Date: Sun, 1 Dec 2024 15:44:43 +0200 Subject: [PATCH 4/5] Use CamelCase --- pmtiles/upload.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pmtiles/upload.go b/pmtiles/upload.go index 71a18a3..f8954e8 100644 --- a/pmtiles/upload.go +++ b/pmtiles/upload.go @@ -19,7 +19,7 @@ func partSizeBytes(totalSize int64) int { } // Upload a pmtiles archive to a bucket. -func Upload(logger *log.Logger, inputpmtiles string, bucket string, remotepmtiles string, maxConcurrency int) error { +func Upload(logger *log.Logger, InputPMTiles string, bucket string, RemotePMTiles string, maxConcurrency int) error { ctx := context.Background() b, err := blob.OpenBucket(ctx, bucket) @@ -28,7 +28,7 @@ func Upload(logger *log.Logger, inputpmtiles string, bucket string, remotepmtile } defer b.Close() - f, err := os.Open(inputpmtiles) + f, err := os.Open(InputPMTiles) if err != nil { return fmt.Errorf("Failed to open file: %w", err) } @@ -44,7 +44,7 @@ func Upload(logger *log.Logger, inputpmtiles string, bucket string, remotepmtile MaxConcurrency: maxConcurrency, } - w, err := b.NewWriter(ctx, remotepmtiles, opts) + w, err := b.NewWriter(ctx, RemotePMTiles, opts) if err != nil { return fmt.Errorf("Failed to obtain writer: %w", err) } From 233794c2e2d1efa05a297dc82756afa212f90414 Mon Sep 17 00:00:00 2001 From: zstadler Date: Mon, 2 Dec 2024 12:58:47 +0200 Subject: [PATCH 5/5] Change CamelCase again Attempt to avoid `` and `` in the help text --- main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index e11e342..b4723fa 100644 --- a/main.go +++ b/main.go @@ -109,8 +109,8 @@ var cli struct { } `cmd:"" help:"Download a local archive to remote storage." hidden:""` Upload struct { - InputPMTiles string `arg:"" type:"existingfile" help:"The local PMTiles file"` - RemotePMTiles string `arg:"" help:"The name for the remote PMTiles source"` + InputPmtiles string `arg:"" type:"existingfile" help:"The local PMTiles file"` + RemotePmtiles string `arg:"" help:"The name for the remote PMTiles source"` MaxConcurrency int `default:"2" help:"# of upload threads"` Bucket string `required:"" help:"Bucket to upload to."` } `cmd:"" help:"Upload a local archive to remote storage."` @@ -204,7 +204,7 @@ func main() { logger.Fatalf("Failed to convert %s, %v", path, err) } case "upload ": - err := pmtiles.Upload(logger, cli.Upload.InputPMTiles, cli.Upload.Bucket, cli.Upload.RemotePMTiles, cli.Upload.MaxConcurrency) + err := pmtiles.Upload(logger, cli.Upload.InputPmtiles, cli.Upload.Bucket, cli.Upload.RemotePmtiles, cli.Upload.MaxConcurrency) if err != nil { logger.Fatalf("Failed to upload file, %v", err)