cmd

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CmdAdd = &cli.Command{
	Name:    "add",
	Usage:   "add an entry",
	Aliases: []string{"l"},
	Description: `Add an entry to a .kdbx database

syntax:
	./kpcli --keyfile <keyfile> \
			--database <database-filename> \
			--pass <pass to open database> \
		add --title <title> \
			--user <username> \
			--pass <password>

Example:
		kpcli add \
			--title new-entry-1 \
			--user example-user1 \
			--pass secret_13

	`,

	Action: runAddEntry,
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:    "entry-title",
			Usage:   "title of new entry",
			Aliases: []string{"t"},
		},
		&cli.StringFlag{
			Name:    "entry-user",
			Usage:   "user of new entry",
			Aliases: []string{"u"},
		},
		&cli.StringFlag{
			Name:    "entry-pass",
			Usage:   "pass of new entry",
			Aliases: []string{"p"},
		},
	},
}
View Source
var CmdCreatedb = &cli.Command{
	Name:    "create",
	Usage:   "Create a new kdbx databse",
	Aliases: []string{"c"},
	Description: `create command create a new kdbx database with few sample entries

Example:
	kpcli \
		--keyfile ./tmp/master-db.key \
		--pass 'super_secret' \
		--db ./tmp/master-db.kdbx \
		create`,

	Action: runCreate,
	Flags: []cli.Flag{
		&cli.IntFlag{
			Name:    "entries",
			Usage:   "number of sample entries",
			Aliases: []string{"e"},
		},
	},
}
View Source
var CmdDiff = &cli.Command{
	Name:    "diff",
	Usage:   "diff entries between 2 kdbx databases",
	Aliases: []string{"d"},
	Description: `Show difference between 2 kdbx databases

syntax:
	kpcli \
		--keyfile <keyfile> \
		--database <database-filename> \
		--pass "${KDBX_PASSWORD}" \
		diff \
			--database2 <database-filename-2>

example:
	kpcli \
		--keyfile ${KDBX_KEYFILE} \
		--database ${KDBX_PASSWORD} \
		--pass "${KDBX_PASSWORD}" \
		diff \
			--database2 ${DATABASE_BACKUP}
	`,

	Action: runDiff,
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:    "database2",
			Usage:   "kdbx files fullpath2",
			Aliases: []string{"db2", "dbfile2"},
			EnvVars: []string{"KDBX_DATABASE2"},
		},

		&cli.StringFlag{
			Name:    "output-format",
			Usage:   "Output format; available: table, csv, markdown, html",
			Aliases: []string{"of2"},
		},
		&cli.StringFlag{
			Name:    "backup-dir",
			Usage:   "dir to look for recent backup file(when database2 is not given)",
			Value:   "./bkups/",
			Aliases: []string{"bkup"},
		},
		&cli.BoolFlag{
			Name:    "notify",
			Usage:   "notify with email",
			Aliases: []string{"n"},
		},
	},
}
View Source
var CmdLs = &cli.Command{
	Name:    "ls",
	Usage:   "lists entries",
	Aliases: []string{"l"},
	Description: `List all entries from a .kdbx database

Example:
	kpcli \
		--keyfile ./tmp/master-db.key \
		--pass 'super_secret' \
		--db ./tmp/master-db.kdbx \
		ls`,

	Action: runLs,
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:    "fields",
			Usage:   "fields list to be displayed",
			Aliases: []string{"f"},
		},
		&cli.BoolFlag{
			Name:    "reverse",
			Usage:   "in reverse order",
			Aliases: []string{"r"},
		},
		&cli.BoolFlag{
			Name:    "quite",
			Usage:   "less verbose",
			Aliases: []string{"q"},
		},
		&cli.StringFlag{
			Name:    "cachefile",
			Usage:   "cache result",
			Aliases: []string{"ca"},
		},
		&cli.StringFlag{
			Name:    "days",
			Usage:   "number of days ; days <= 0 means all",
			Aliases: []string{"d"},
		},
		&cli.StringFlag{
			Name:    "sortby-col",
			Usage:   "sort by column number starting 1",
			Aliases: []string{"sb"},
		},
		&cli.StringFlag{
			Name:    "output-format",
			Usage:   "Output format; available: table, csv, markdown, html",
			Aliases: []string{"of"},
		},
	},
}
View Source
var (
	TimeLayout = "2006-01-02 15:04:05"
)

Functions

func CopyFile

func CopyFile(cur, new string) error

func CreateNewEntry

func CreateNewEntry(t, u, p string) gokeepasslib.Entry

func GenerateKDBXEntries

func GenerateKDBXEntries(n int) []gokeepasslib.Entry

func MkProtectedValue

func MkProtectedValue(key string, value string) gokeepasslib.ValueData

func MkValue

func MkValue(key string, value string) gokeepasslib.ValueData

func NewDB

func NewDB(opts Options) (*db, error)

NewDB create and return a new kdbx db object

Types

type Diff

type Diff struct {
	ToDBOption   *Options
	FromDBOption *Options
	// contains filtered or unexported fields
}

func NewDiff

func NewDiff(opts Options) *Diff

NewDiff returns a *Diff

func (*Diff) Diff

func (d *Diff) Diff() error

Diff shows the difference between 2 databases notify option can be used to notify your email id (work only for gmail at the moment)

func (*Diff) Notify

func (d *Diff) Notify(contentFile string)

type Interested

type Interested struct {
	Created   time.Time
	Histories int
	KeyValues map[string]string
	Modified  time.Time
	Pass      string
	Tags      string
	Title     string
	User      string
}

type Options

type Options struct {
	BackupDIR      string
	CacheFile      string
	Database       string
	Database2      string
	Days           int
	DiffCalling    bool
	EntryPass      string
	EntryTitle     string
	EntryUser      string
	Fields         string
	Key            string
	Key2           string
	LogLevel       string
	Notify         bool
	OutputFilename string
	OutputFormat   string
	Pass           string
	Pass2          string
	Quite          bool
	Reverse        bool
	SampleEntries  int
	Sort           string
	SortbyCol      int
}

Options holds the cli options

func (*Options) String

func (o *Options) String() string

Jump to

Keyboard shortcuts

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