cmd

package
v1.0.31 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 23 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{"a"},
	Description: `Add an entry to a .kdbx database

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

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

		task add-entry
	`,

	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"},
		},
	},
}

CmdAdd helps user to add entry to password db

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
		
	kpcli \
		--nokey \
		--pass 'super_secret' \
		--db ./tmp/master-db.kdbx \
		create
		
		`,

	Action: runCreate,
	Flags: []cli.Flag{
		&cli.IntFlag{
			Name:    "sample-entries",
			Usage:   "number of sample entries",
			Aliases: []string{"se"},
		},
	},
}

CmdCreatedb creates password db

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"},
		},
	},
}

CmdDiff runs diff between 2 passward dbs

View Source
var CmdGenerateSampleConfig = &cli.Command{
	Name:    "generate-sample-config",
	Usage:   "generate sample config file: kpcli.toml",
	Aliases: []string{"gen"},
	Description: `generate sample config file: kpcli.toml

Example:
	kpcli \
		generate-sample-config
	`,
	Action: runGenerateSampleConfig,
}

CmdGenerateSampleConfig generate a sample config

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

	kpcli \
		--nokey \
		--pass 'super_secret' \
		--db ./tmp/master-db.kdbx \
		ls

	kpcli \
		--keyfile ./tmp/master-db.key \
		--pass 'super_secret' \
		--db ./tmp/master-db.kdbx \
		ls \
		--fields few

	Fields options:
		all		: {cols[0], cols[1], cols[2], cols[3], cols[4]}
		few		: {cols[0]}
		default	: {cols[0], cols[1], cols[2], cols[3]}
		`,

	Action: runLs,
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:    "fields",
			Usage:   "fields list to be displayed, available options: all|few",
			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"},
		},
	},
}

CmdLs lists entries from a db

View Source
var (
	// Note: credsFile used by cmds: [ add, create ]
	// credsFile  = "./tmp/master-db.creds"
	TimeLayout = "2006-01-02 15:04:05"
)

Functions

func CreateNewEntry

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

func GenerateKDBXEntries

func GenerateKDBXEntries(n int) []gokeepasslib.Entry

func InitGetLogger added in v1.0.31

func InitGetLogger(logLvl string) *logrus.Logger

func LoadConfigOnDemand added in v1.0.31

func LoadConfigOnDemand(configFile string)

LoadConfigOnDemand loads config if present

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 models.Options) (*kdbx, error)

Types

type Client added in v1.0.31

type Client models.Client

func (*Client) CreateKDBX added in v1.0.31

func (c *Client) CreateKDBX() (*gokeepasslib.Database, error)

func (*Client) PreVerifyCreate added in v1.0.31

func (c *Client) PreVerifyCreate() error

NewDB creates and returns a new kdbx database

type Diff

type Diff models.Diff

func NewDiff

func NewDiff(opts *models.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)

Jump to

Keyboard shortcuts

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