8bba490c30
There is a need to support NeoFS-binary sessions along with JSON ones in NeoFS CLI. Provide generic `common.ReadBinaryOrJSON` functions which tries to decode NeoFS-binary structure and falls back to JSON format. Use this function in all places with token reading. Signed-off-by: Leonard Lyubich <ctulhurider@gmail.com>
19 lines
440 B
Go
19 lines
440 B
Go
package commonflags
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
const SessionToken = "session"
|
|
|
|
// InitSession registers SessionToken flag representing filepath to the token
|
|
// of the session with the given name. Supports NeoFS-binary and JSON files.
|
|
func InitSession(cmd *cobra.Command, name string) {
|
|
cmd.Flags().String(
|
|
SessionToken,
|
|
"",
|
|
fmt.Sprintf("Filepath to a JSON- or binary-encoded token of the %s session", name),
|
|
)
|
|
}
|