syncm

package
v0.2.25 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoSync

func AutoSync(file string) error

AutoSync syncs snippets automatically

func BackupFiles

func BackupFiles(syncFiles SyncInfos, outputPath string) error

func ReplaceDirFromSign

func ReplaceDirFromSign(dirPath string, homeDir string, confDir string) (string, bool)

func ReplaceDirToSign

func ReplaceDirToSign(filePath string, homeDir string, confDir string) (string, bool)

func RestoreFiles

func RestoreFiles(bkpFilePath string, restoreDir string) error

Types

type Backups

type Backups struct {
	Files []FileInfo `yaml:"files"`
}

func (*Backups) Load

func (backups *Backups) Load() error

Load reads yaml file.

func (*Backups) Order

func (backups *Backups) Order()

func (*Backups) Reverse

func (backups *Backups) Reverse()

func (*Backups) Save

func (backups *Backups) Save() error

Save saves the backups to yaml file.

func (*Backups) ToString

func (backups *Backups) ToString() (string, error)

type Client

type Client interface {
	GetSnippet() (*Snippet, error)
	UploadSnippet(string) error
}

Client manages communication with the remote Snippet repository

func NewGistClient

func NewGistClient() (Client, error)

NewGistClient returns GistClient

func NewGitLabClient

func NewGitLabClient() (Client, error)

NewGitLabClient returns GitLabClient

func NewSyncClient

func NewSyncClient() (Client, error)

NewSyncClient returns Client

type FileInfo

type FileInfo struct {
	FileContent string            `yaml:"filecontent,omitempty"`
	Metadata    map[string]string `yaml:"metadata"`
}

type GistClient

type GistClient struct {
	Client *github.Client
	ID     string
}

GistClient manages communication with Gist

func (GistClient) GetSnippet

func (g GistClient) GetSnippet() (*Snippet, error)

GetSnippet returns the remote snippet

func (GistClient) UploadSnippet

func (g GistClient) UploadSnippet(content string) error

UploadSnippet uploads local snippets to Gist

type GitLabClient

type GitLabClient struct {
	Client *gitlab.Client
	ID     int
}

GitLabClient manages communication with GitLab Snippets

func (GitLabClient) GetSnippet

func (g GitLabClient) GetSnippet() (*Snippet, error)

GetSnippet returns the remote snippet

func (GitLabClient) UploadSnippet

func (g GitLabClient) UploadSnippet(content string) error

UploadSnippet uploads local snippets to GitLab Snippet

type Snippet

type Snippet struct {
	Content   string
	UpdatedAt time.Time
}

Snippet is the remote snippet

type SyncInfo

type SyncInfo struct {
	FilePath string            `yaml:"filepath,omitempty"`
	Metadata map[string]string `yaml:"metadata"`
}

type SyncInfos

type SyncInfos struct {
	Files []SyncInfo `yaml:"files"`
}

func (*SyncInfos) Load

func (syncInfos *SyncInfos) Load() error

Load reads yaml file.

func (*SyncInfos) Order

func (syncInfos *SyncInfos) Order()

func (*SyncInfos) Reverse

func (syncInfos *SyncInfos) Reverse()

func (*SyncInfos) Save

func (syncInfos *SyncInfos) Save() error

Save saves the syncInfos to yaml file.

func (*SyncInfos) ToString

func (syncInfos *SyncInfos) ToString() (string, error)

Jump to

Keyboard shortcuts

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