Skip to content

Commit

Permalink
Update pmtiles upload --help (#195)
Browse files Browse the repository at this point in the history
* Update `pmtiles upload --help` [#194]
  • Loading branch information
zstadler authored Dec 4, 2024
1 parent a23ec20 commit afd53c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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."`
Expand Down Expand Up @@ -203,8 +203,8 @@ func main() {
if err != nil {
logger.Fatalf("Failed to convert %s, %v", path, err)
}
case "upload <input> <key>":
err := pmtiles.Upload(logger, cli.Upload.Input, cli.Upload.Bucket, cli.Upload.Key, cli.Upload.MaxConcurrency)
case "upload <inputpmtiles> <remotepmtiles>":
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)
Expand Down
6 changes: 3 additions & 3 deletions pmtiles/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand Down

0 comments on commit afd53c9

Please sign in to comment.