storj/cmd/uplink/cmd_access_export.go
Márton Elek ea1408f7a8 go.mod: bump clingy dependency
As a reminder: latest clingy removed the requirement of having custom context (which made the usage of context.WithValue harder) and uses simple context instead.

Clingy saves the stdin/stdout/stderr to the context (earlier to separated context type) to make it available for unit testing.

Change-Id: I8896574f4670721de43a577cd4b35952e3b5d00e
2022-08-31 10:24:27 +00:00

43 lines
876 B
Go

// Copyright (C) 2021 Storj Labs, Inc.
// See LICENSE for copying information.
package main
import (
"context"
"github.com/zeebo/clingy"
"github.com/zeebo/errs"
"storj.io/storj/cmd/uplink/ulext"
)
type cmdAccessExport struct {
ex ulext.External
name string
filename string
}
func newCmdAccessExport(ex ulext.External) *cmdAccessExport {
return &cmdAccessExport{ex: ex}
}
func (c *cmdAccessExport) Setup(params clingy.Parameters) {
c.name = params.Arg("name", "Name of the access to export").(string)
c.filename = params.Arg("filename", "Name of the file to save to").(string)
}
func (c *cmdAccessExport) Execute(ctx context.Context) error {
if c.filename == "" {
return errs.New("Must specify a filename to write to.")
}
access, err := c.ex.OpenAccess(c.name)
if err != nil {
return err
}
return c.ex.ExportAccess(ctx, access, c.filename)
}