func getAttachments(cmd *cobra.Command) (types.Attachments, error) {
	mediasStrings, err := cmd.Flags().GetStringArray(FlagAttachment)
	if err != nil {
		return nil, fmt.Errorf("invalid flag value: %s", FlagAttachment)
	}
	attachments := types.Attachments{}
	for _, mediaString := range mediasStrings {
		argz := strings.Split(mediaString, ",")
		var tags []string
		if len(argz) < 2 {
			return nil, fmt.Errorf("if attachments are specified, the arguments has to be at least 2 and in this order: \"URI,Mime-Type\", please use the --help flag to know more")
		} else if len(argz) > 2 {
			tags = append(tags, argz[2:]...)
		}
		attachment := types.NewAttachment(argz[0], argz[1], tags)
		attachments = attachments.AppendIfMissing(attachment)
	}
	return attachments, nil
}
getAttachments parses the attachments of a post.
If one or more attachments are found, it returns them. Otherwise returns `nil` instead.
package cli
import (
	"fmt"
	"strconv"
	"strings"
	"time"
	"github.com/cosmos/cosmos-sdk/client/flags"
	"github.com/cosmos/cosmos-sdk/client/tx"
	sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
	"github.com/cosmos/cosmos-sdk/version"
	"github.com/spf13/cobra"
	"github.com/cosmos/cosmos-sdk/client"
	"github.com/desmos-labs/desmos/v2/x/staging/posts/types"
)
func NewTxCmd() *cobra.Command {
	postsTxCmd := &cobra.Command{
		Use:                        types.ModuleName,
		Short:                      "Posts transaction subcommands",
		DisableFlagParsing:         true,
		SuggestionsMinimumDistance: 2,
		RunE:                       client.ValidateCmd,
	}
	postsTxCmd.AddCommand(
		GetCmdCreatePost(),
		GetCmdEditPost(),
		GetCmdReportPost(),
		GetCmdAddPostReaction(),
		GetCmdRemovePostReaction(),
		GetCmdAnswerPoll(),
		GetCmdRegisterReaction(),
	)
	return postsTxCmd
}