watcher

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2020 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

Package watcher is the implementation of the application regardless of CLI or UI

Index

Constants

View Source
const DefaultConfigurationPath = "./.watcher.yaml"

DefaultConfigurationPath is the default path for the settings file

View Source
const DefaultDatabasePath = "./watcher.db"

DefaultDatabasePath is the default path for the database file

Variables

This section is empty.

Functions

This section is empty.

Types

type AppConfiguration

type AppConfiguration struct {
	ConfigurationFile string
	LogLevel          string
	// database file location
	Database string
	// backup options
	Backup struct {
		BackupSettings
		Archive struct {
			Zip  bool
			Tar  bool
			Gzip bool
		}
	}
	Restore struct {
		BackupSettings
	}
	// cli specific options
	Cli struct {
		DisableColors            bool
		ForceColors              bool
		DisableTimestamp         bool
		UseUppercaseLevel        bool
		UseTimePassedAsTimestamp bool
	}
	// sentry toggles
	EnableSentry  bool
	DisableSentry bool
	// run specific options
	Run struct {
		RunParallel       bool
		Items             []string
		DownloadDirectory string
		ModuleURL         []string
		DisableURL        []string
	}
}

AppConfiguration contains the persistent configurations/settings across all commands

type BackupSettings

type BackupSettings struct {
	Database struct {
		Accounts struct {
			Enabled bool
		}
		Items struct {
			Enabled bool
		}
		OAuth2Clients struct {
			Enabled bool
		}
		Cookies struct {
			Enabled bool
		}
		SQL bool
	}
	Settings bool
}

BackupSettings are the possible configuration settings for backups and recoveries

type NoReaderFoundError

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

NoReaderFoundError is the error in case the file has no recognized extension

func (NoReaderFoundError) Error

func (e NoReaderFoundError) Error() string

Error prints the error details for our custom error

type Watcher

type Watcher struct {
	DbCon         *database.DbIO
	ModuleFactory *modules.ModuleFactory
	Cfg           *AppConfiguration
}

Watcher contains the database connection and module factory of the main application

func NewWatcher

func NewWatcher(cfg *AppConfiguration) *Watcher

NewWatcher initializes a new Watcher with the default settings

func (*Watcher) AddAccountByURI

func (app *Watcher) AddAccountByURI(uri string, user string, password string)

AddAccountByURI extracts the module based on the uri and adds an account if not registered already

func (*Watcher) AddCookieByURI

func (app *Watcher) AddCookieByURI(uri string, name string, value string, expiration string)

AddCookieByURI adds a cookie based on the uri

func (*Watcher) AddItemByURI

func (app *Watcher) AddItemByURI(uri string, currentItem string)

AddItemByURI adds an item based on the uri and sets it to the passed current item if not nil

func (*Watcher) AddOAuthClientByURI

func (app *Watcher) AddOAuthClientByURI(
	uri string, clientID string, clientSecret string, accessToken string, refreshToken string,
)

AddOAuthClientByURI adds an OAuth2 client based on the uri

func (*Watcher) Backup

func (app *Watcher) Backup(archiveName string, cfg *AppConfiguration)

Backup backs up the full database and the configuration

func (*Watcher) ListAccounts

func (app *Watcher) ListAccounts(uri string)

ListAccounts lists all accounts with the option to limit it to a module

func (*Watcher) ListCookies

func (app *Watcher) ListCookies(uri string)

ListCookies lists all cookies with the option to limit it to a module

func (*Watcher) ListOAuthClients

func (app *Watcher) ListOAuthClients(uri string)

ListOAuthClients lists all OAuth2 clients with the option to limit it to a module

func (*Watcher) ListRegisteredModules

func (app *Watcher) ListRegisteredModules(uri string)

ListRegisteredModules lists all registered modules

func (*Watcher) ListTrackedItems

func (app *Watcher) ListTrackedItems(uri string, includeCompleted bool)

ListTrackedItems lists all tracked items with the option to limit it to a module

func (*Watcher) Restore

func (app *Watcher) Restore(archiveName string, cfg *AppConfiguration)

Restore restores the database/settings from the passed archive

func (*Watcher) Run

func (app *Watcher) Run()

Run is the main functionality, updates all tracked items either parallel or linear

Jump to

Keyboard shortcuts

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