commands

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2020 License: GPL-3.0 Imports: 41 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, sessionBase64 bool)

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 delete 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, token, username string)

SetupClient sets up client config

func ShredderFile

func ShredderFile(localFile string, size int64)

ShredderFile shreddres a file

func UnPublishFile added in v1.4.5

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

UnPublishFile makes a public file private

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 Bar added in v1.4.5

type Bar struct {
	// contains filtered or unexported fields
}

Bar a porgressbar

func NewBar added in v1.4.5

func NewBar(task BarTask, total int64, name string, singleMode bool) *Bar

NewBar create a new bar

type BarTask added in v1.4.5

type BarTask uint8

BarTask for the bar to do

const (
	UploadTask BarTask = iota
	DownloadTask
)

...

func (BarTask) String added in v1.4.5

func (bt BarTask) String() string

Implement string

func (BarTask) Verb added in v1.4.5

func (bt BarTask) Verb() string

Verb return task as verb

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
	Compression             bool
	Extract                 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(downloadData *DownloadData) (*libdm.FileDownloadResponse, error)

DownloadFile download a file specified by data

func (*CommandData) DownloadNamespace added in v1.4.1

func (cData *CommandData) DownloadNamespace(exGroups, exTags, exFiles []string, parallelism int, outDir string)

DownloadNamespace download files from namespace

func (*CommandData) EditFile

func (cData *CommandData) EditFile(name string, id uint, editor string)

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) UploadItems added in v1.4.5

func (cData *CommandData) UploadItems(uris []string, threads int, uploadData *UploadData)

UploadItems to the server and set's its affiliations

func (*CommandData) ViewFile

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

ViewFile view file

type DownloadData

type DownloadData struct {
	FileName  string
	FileID    uint
	LocalPath string
	Preview   bool

	ProgressView *ProgressView
}

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 HashBench added in v1.4.5

type HashBench struct {
	// contains filtered or unexported fields
}

HashBench benchmarks crc32

func NewHashBench added in v1.4.5

func NewHashBench() *HashBench

NewHashBench create a new hashBench

func (HashBench) DoTest added in v1.4.5

func (ht HashBench) DoTest() int

DoTest runs the hash test

type ProgressView added in v1.4.5

type ProgressView struct {
	ProgressContainer *mpb.Progress
	Bars              []*mpb.Bar
	RawBars           []*Bar
}

ProgressView holds info for progress

func NewProgressView added in v1.4.5

func NewProgressView() *ProgressView

NewProgressView create new progressview

func (*ProgressView) AddBar added in v1.4.5

func (pv *ProgressView) AddBar(bbar *Bar) *mpb.Bar

AddBar to ProgressView

type UploadData

type UploadData struct {
	Name          string
	PublicName    string
	FromStdIn     bool
	SetClip       bool
	Public        bool
	ReplaceFile   uint
	DeleteInvalid bool
	TotalFiles    int
	ProgressView  *ProgressView
	NoArchiving   bool
	// contains filtered or unexported fields
}

UploadData data for uploads

Jump to

Keyboard shortcuts

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