internal

package
v3.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DBLsCmd = &Command{
		Usage: "ls",
		Short: "list the databases configured",
		Run:   dbLsCmd,
	}

	DBSetCmd = &Command{
		Usage: "set <name> <type> <dsn>",
		Short: "set the database connection",
		Run:   dbSetCmd,
	}

	DBRmCmd = &Command{
		Usage: "rm <name,...>",
		Short: "remove a database connection",
		Run:   dbRmCmd,
	}
)
View Source
var (
	AddCmd = &Command{
		Usage: "add [comment]",
		Short: "add a new revision",
		Long: `Add will open up the editor specified via EDITOR for creating the new revision.
The -c flag can be given to specify a category for the new revision.`,
		Run: addCmd,
	}
)
View Source
var CatCmd = &Command{
	Usage: "cat <revisions,...>",
	Short: "display the given revisions",
	Long:  `Cat will print out the given revisions`,
	Run:   catCmd,
}
View Source
var LogCmd = &Command{
	Usage: "log",
	Short: "log the performed revisions",
	Long: `Log displays all of the revisions that have been performed in the given
database. The -n flag can be given to limit the number of revisions that are
shown in the log. The database to connect to is specified via the -type and
-dsn flags, or via the -db flag if a database connection has been configured
via the "mgrt db" command.

The -type flag specifies the type of database to connect to, it will be one of,

    mysql
    postgresql
    sqlite3

The -dsn flag specifies the data source name for the database. This will vary
depending on the type of database you're connecting to.

mysql and postgresql both allow for the URI connection string, such as,

    type://[user[:password]@][host]:[port][,...][/dbname][?param1=value1&...]

where type would either be mysql or postgresql. The postgresql type also allows
for the DSN string such as,

    host=localhost port=5432 dbname=mydb connect_timeout=10

sqlite3 however will accept a filepath, or the :memory: string, for example,

    -dsn :memory:`,
	Run: logCmd,
}
View Source
var LsCmd = &Command{
	Usage: "ls",
	Short: "list revisions",
	Long:  `List will display all of the revisions you have.`,
	Run:   lsCmd,
}
View Source
var RunCmd = &Command{
	Usage: "run <revisions,...>",
	Short: "run the given revisions",
	Long: `Run will perform the given revisions against the given database. The database
to connect to is specified via the -type and -dsn flags, or via the -db flag if a database
connection has been configured via the "mgrt db" command.

The -c flag specifies the category of revisions to run. If not given, then the
default revisions will be run.

The -type flag specifies the type of database to connect to, it will be one of,

    mysql
    postgresql
    sqlite3

The -dsn flag specifies the data source name for the database. This will vary
depending on the type of database you're connecting to.

mysql and postgresql both allow for the URI connection string, such as,

    type://[user[:password]@][host]:[port][,...][/dbname][?param1=value1&...]

where type would either be mysql or postgresql. The postgresql type also allows
for the DSN string such as,

    host=localhost port=5432 dbname=mydb connect_timeout=10

sqlite3 however will accept a filepath, or the :memory: string, for example,

    -dsn :memory:`,
	Run: runCmd,
}
View Source
var ShowCmd = &Command{
	Usage: "show [revision]",
	Short: "show the given revision",
	Long: `Show will show the SQL that was run in the given revision. If no revision is
specified, then the latest revision will be shown, if any. The database to connect to is
specified via the -type and -dsn flags, or via the -db flag if a database connection has
been configured via the "mgrt db" command.

The -type flag specifies the type of database to connect to, it will be one of,

    mysql
    postgresql
    sqlite3

The -dsn flag specifies the data source name for the database. This will vary
depending on the type of database you're connecting to.

mysql and postgresql both allow for the URI connection string, such as,

    type://[user[:password]@][host]:[port][,...][/dbname][?param1=value1&...]

where type would either be mysql or postgresql. The postgresql type also allows
for the DSN string such as,

    host=localhost port=5432 dbname=mydb connect_timeout=10

sqlite3 however will accept a filepath, or the :memory: string, for example,

    -dsn :memory:`,
	Run: showCmd,
}
View Source
var SyncCmd = &Command{
	Usage: "sync <-type type> <-dsn dsn>",
	Short: "sync the performed revisions",
	Long: `Sync will update the local revisions with what has been performed in the
database. Doing this will overwrite any pre-existing revisions you may have
locally. The database to connect to is specified via the -type and -dsn flags,
or via the -db flag if a database connection has been configured via the "mgrt db"
command.

The -type flag specifies the type of database to connect to, it will be one of,

    mysql
    postgresql
    sqlite3

The -dsn flag specifies the data source name for the database. This will vary
depending on the type of database you're connecting to.

mysql and postgresql both allow for the URI connection string, such as,

    type://[user[:password]@][host]:[port][,...][/dbname][?param1=value1&...]

where type would either be mysql or postgresql. The postgresql type also allows
for the DSN string such as,

    host=localhost port=5432 dbname=mydb connect_timeout=10

sqlite3 however will accept a filepath, or the :memory: string, for example,

    -dsn :memory:`,
	Run: syncCmd,
}

Functions

This section is empty.

Types

type Command

type Command struct {
	Argv0 string // Argv0 is the name of the process running the command.
	Usage string // Usage is the usage line of the command.
	Short string // Short is a short description of what the command does.
	Long  string // Long is a longer more in depth description of the command.

	// Run is the function that will actually execute the command. This will
	// be passed a pointer to the Command itself, along with the arguments
	// given to it. The first item in the arguments list will be the command
	// name.
	Run func(*Command, []string)

	// Commands is the set of sub-commands the command could have.
	Commands *CommandSet
}

func DBCmd

func DBCmd(argv0 string) *Command

func HelpCmd

func HelpCmd(cmds *CommandSet) *Command

type CommandSet

type CommandSet struct {
	Argv0 string
	Long  string
	Usage func()
	// contains filtered or unexported fields
}

func (*CommandSet) Add

func (c *CommandSet) Add(name string, cmd *Command)

func (*CommandSet) Parse

func (c *CommandSet) Parse(args []string) error

type ErrCommandNotFound

type ErrCommandNotFound string

func (ErrCommandNotFound) Error

func (e ErrCommandNotFound) Error() string

Jump to

Keyboard shortcuts

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