storj/cmd/uplinkng/cmd_access_export.go
Jeff Wendling b7ca2289e0 cmd/uplinkng: improvements to prepare for doc update
* improve setup wizard
* added access grant file support
* improved consistency across commands
* a couple bug fixes
* added access import and export

Change-Id: I30ad9d4771f15430904a503a4d465bc40be471b5
2022-01-31 17:37:54 +00:00

41 lines
865 B
Go

// Copyright (C) 2021 Storj Labs, Inc.
// See LICENSE for copying information.
package main
import (
"github.com/zeebo/clingy"
"github.com/zeebo/errs"
"storj.io/storj/cmd/uplinkng/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 clingy.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)
}