commands

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2020 License: MIT Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GreenSuccessfully = color.HiGreenString("Successfully")
	RedError          = color.HiRedString("Error")
)

Colorized strings

View Source
var AvailableOrders = []string{"id", "name", "size", "pubname", "created", "namespace"}

AvailableOrders options fo ordering

View Source
var (
	// ErrAbortDeletion if user canceled interaction
	ErrAbortDeletion = errors.New("aborted")
)
View Source
var ReversedSuffixes = []string{"r", "d"}

ReversedSuffixes suffixes for reversing sort

View Source
var UseTargets = []string{"namespace", "tags", "groups"}

UseTargets targets for config use

Functions

func ConfigUse

func ConfigUse(cData *CommandData, target string, values []string)

ConfigUse command for config use

func ConfigView

func ConfigView(cData *CommandData)

ConfigView view config

func CreateKeystore

func CreateKeystore(cData *CommandData, path string, overwrite bool)

CreateKeystore create a keystore

func CreateNamespace

func CreateNamespace(cData *CommandData, name string, customNS bool)

CreateNamespace creates a namespace

func DeleteAttribute

func DeleteAttribute(cData *CommandData, attribute libdm.Attribute, name string)

DeleteAttribute update an attribute

func DeleteFile

func DeleteFile(cData *CommandData, name string, id uint)

DeleteFile deletes the desired file(s)

func DeleteNamespace

func DeleteNamespace(cData *CommandData, name string)

DeleteNamespace update a namespace

func GetFileCommandData

func GetFileCommandData(n string, fid uint) (name string, id uint)

GetFileCommandData returns id if name is id

func GetTempFile

func GetTempFile(fileName string) string

GetTempFile returns tempfile from fileName

func IsOrderReversed

func IsOrderReversed(str string) bool

IsOrderReversed return true if order should be reversed

func KeystoreAddKey

func KeystoreAddKey(cData *CommandData, keyFile string, fileID uint)

KeystoreAddKey adds key to keystore

func KeystoreCleanup

func KeystoreCleanup(cData *CommandData, shredderCount uint)

KeystoreCleanup cleansup a keystore

func KeystoreDelete

func KeystoreDelete(cData *CommandData, shredderCount uint)

KeystoreDelete delete a keystore

func KeystoreInfo

func KeystoreInfo(cData *CommandData)

KeystoreInfo shows info for keystore

func KeystoreRemoveKey

func KeystoreRemoveKey(cData *CommandData, fileID uint)

KeystoreRemoveKey removes key from keystore

func ListFiles

func ListFiles(cData *CommandData, name string, id uint, sOrder string)

ListFiles lists the files corresponding to the args

func ListNamespace

func ListNamespace(cData *CommandData)

ListNamespace lists your namespace

func LoginCommand

func LoginCommand(cData *CommandData, usernameArg string, args ...bool)

LoginCommand login into the server

func Ping

func Ping(cData *CommandData)

Ping pings the server

func ProcesStrSliceParam

func ProcesStrSliceParam(slice *[]string)

ProcesStrSliceParam divides args by ,

func ProcesStrSliceParams

func ProcesStrSliceParams(slices ...*[]string)

ProcesStrSliceParams divides args by ,

func PublishFile

func PublishFile(cData *CommandData, name string, id uint, publicName string, setClip bool)

PublishFile publishes a file

func RegisterCommand

func RegisterCommand(cData *CommandData)

RegisterCommand create a new account

func SetupClient

func SetupClient(cData *CommandData, host, configFile string, ignoreCert, serverOnly, register, noLogin bool)

SetupClient sets up client config

func ShredderFile

func ShredderFile(localFile string, size int64)

ShredderFile shreddres a file

func UpdateAttribute

func UpdateAttribute(cData *CommandData, attribute libdm.Attribute, name, newName string)

UpdateAttribute update an attribute

func UpdateFile

func UpdateFile(cData *CommandData, name string, id uint, newName string, newNamespace string, addTags []string, removeTags []string, addGroups []string, removeGroups []string, setPublic, setPrivate bool)

UpdateFile updates a file on the server

func UpdateNamespace

func UpdateNamespace(cData *CommandData, name, newName string, customNS bool)

UpdateNamespace update a namespace

Types

type CommandData

type CommandData struct {
	LibDM   *libdm.LibDM
	Command string
	Config  *dmConfig.Config

	EncryptionKey       []byte
	Encryption, Keyfile string
	RandKey             int

	Namespace               string
	UnmodifiedNamespace     string
	FileAttributes          libdm.FileAttributes
	Details                 uint8
	NameLen                 int
	All, AllNamespaces      bool
	NoRedaction, OutputJSON bool
	Yes, Force, Quiet       bool
	NoDecrypt, NoEmojis     bool
	VerifyFile              bool
	// contains filtered or unexported fields
}

CommandData data for commands

func (*CommandData) CloseKeystore

func (cData *CommandData) CloseKeystore()

CloseKeystore closes keystoree

func (*CommandData) CreateFile added in v1.4.0

func (cData *CommandData) CreateFile(name string)

CreateFile create a file and upload it

func (*CommandData) DownloadFile

func (cData *CommandData) DownloadFile(data *DownloadData)

DownloadFile view file

func (*CommandData) EditFile

func (cData *CommandData) EditFile(id uint)

EditFile edits a file

func (*CommandData) FileTree added in v1.4.0

func (cData *CommandData) FileTree(sOrder, namespace string)

FileTree shows a unix tree like view of files

func (*CommandData) GetKeystore

func (cData *CommandData) GetKeystore() (*libdm.Keystore, error)

GetKeystore returns the keystore for user

func (*CommandData) HasKeystoreSupport

func (cData *CommandData) HasKeystoreSupport() bool

HasKeystoreSupport return true if kesytore is set up correctly and is enabled

func (*CommandData) Init

func (cData *CommandData) Init() bool

Init init CommandData

func (*CommandData) ListAttributes added in v1.4.0

func (cData *CommandData) ListAttributes(attribute libdm.Attribute)

ListAttributes lists attributes in a namespace

func (*CommandData) Logout added in v1.4.0

func (cData *CommandData) Logout(username string)

Logout Logs out the user

func (*CommandData) RequestedEncryptionInput

func (cData *CommandData) RequestedEncryptionInput() bool

RequestedEncryptionInput determine if encryption input was requested

func (*CommandData) UploadFile

func (cData *CommandData) UploadFile(uris []string, threads uint, uploadData *UploadData)

UploadFile uploads the given file to the server and set's its affiliations

func (*CommandData) ViewFile

func (cData *CommandData) ViewFile(data *DownloadData)

ViewFile view file

type DownloadData

type DownloadData struct {
	FileName  string
	FileID    uint
	LocalPath string
	Preview   bool
	NoPreview bool
	// contains filtered or unexported fields
}

DownloadData information for downloading files

type FileOrder

type FileOrder int16

FileOrder order/sort stuff

const (
	NoOrder FileOrder = iota
	IDOrder
	NameOrder
	SizeOrder
	PubNameOrder
	CreatedOrder
	NamespaceOrder
)

Order

func FileOrderFromString

func FileOrderFromString(str string) *FileOrder

FileOrderFromString return order from string

type FileSorter

type FileSorter struct {
	Files   []*libdm.FileResponseItem
	Reverse bool
}

FileSorter a sorter

func NewFileSorter

func NewFileSorter(files []*libdm.FileResponseItem) *FileSorter

NewFileSorter create a new sorter

func (*FileSorter) Reversed

func (sorter *FileSorter) Reversed(reversed bool) *FileSorter

Reversed Sort reversed

func (FileSorter) SortBy

func (sorter FileSorter) SortBy(by FileOrder)

SortBy order files

type UploadData

type UploadData struct {
	Name          string
	Publicname    string
	FromStdIn     bool
	SetClip       bool
	Public        bool
	ReplaceFile   uint
	DeleteInvalid bool
	TotalFiles    int
	Progress      *uiprogress.Progress
}

UploadData data for uploads

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL