internal

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Example (GroupInfoCommand_Run)
var dbFile = rrh.Rollback("../testdata/test_db.json", "../testdata/config.json", func(config *rrh.Config, db *rrh.Database) {
	var gic, _ = groupInfoCommandFactory()
	gic.Run([]string{"group1", "group2", "groupN"})
})
defer os.Remove(dbFile)
Output:
group1: desc1 (1 repository, omit: false)
group2: desc2 (0 repositories, omit: false)
groupN: group not found
Example (GroupListCommand_Run)
var dbFile = rrh.Rollback("../testdata/test_db.json", "../testdata/config.json", func(config *rrh.Config, db *rrh.Database) {
	var glc, _ = groupListCommandFactory()
	glc.Run([]string{"-d", "-r"})
})
defer os.Remove(dbFile)
Output:
group1,desc1,[repo1],1 repository
group2,desc2,[],0 repositories
group3,desc3,[repo2],1 repository
Example (GroupOfCommand_Run)
var dbFile = rrh.Rollback("../testdata/test_db.json", "../testdata/config.json", func(config *rrh.Config, db *rrh.Database) {
	var goc, _ = groupOfCommandFactory()
	goc.Run([]string{"repo1"})
})
defer os.Remove(dbFile)
Output:
repo1, [group1]
Example (ListCommand_Run)
os.Setenv(rrh.ConfigPath, "../testdata/config.json")
os.Setenv(rrh.Home, "../testdata/")
os.Unsetenv(rrh.DatabasePath)
var clc, _ = configListCommandFactory()
clc.Run([]string{})
Output:
RRH_AUTO_CREATE_GROUP: true (config_file)
RRH_AUTO_DELETE_GROUP: false (config_file)
RRH_CLONE_DESTINATION: . (default)
RRH_COLOR: repository:fg=red+group:fg=magenta+label:op=bold+configValue:fg=green (default)
RRH_CONFIG_PATH: ../testdata/config.json (environment)
RRH_DATABASE_PATH: ../testdata/database.json (default)
RRH_DEFAULT_GROUP_NAME: no-group (default)
RRH_ENABLE_COLORIZED: false (default)
RRH_HOME: ../testdata/ (environment)
RRH_ON_ERROR: WARN (default)
RRH_SORT_ON_UPDATING: true (config_file)
RRH_TIME_FORMAT: relative (default)
Example (NotFound)
oc, _ := OpenCommandFactory()
oc.Run([]string{"not_exist_repo"})
Output:
not_exist_repo: repository not found
Example (PrintHelp)
oc, _ := OpenCommandFactory()
oc.Run([]string{"-h"})
Output:
rrh open [OPTIONS] <REPOSITORIES...>
OPTIONS
    -f, --folder     open the folder of the specified repository (Default).
    -w, --webpage    open the webpage of the specified repository.
    -h, --help       print this message.
ARGUMENTS
    REPOSITORIES     specifies repository names.
Example (RepositoryUpdateRemotesCommand_Run)
var dbFile = rrh.Rollback("../testdata/remotes.json", "../testdata/config.json", func(config *rrh.Config, oldDB *rrh.Database) {
	var command, _ = repositoryUpdateRemotesCommandFactory()
	command.Run([]string{"--verbose", "--dry-run"})
})
defer os.Remove(dbFile)
Output:
{ origin:git@github.com:tamada/fibonacci.git } -> { origin:https://htamada@bitbucket.org/htamada/fibonacci.git }
{  } -> { origin:https://htamada@bitbucket.org/htamada/helloworld.git }

Index

Examples

Constants

View Source
const (
	GroupType targetKind = iota + 1
	RepositoryType
	GroupAndRepoType
	GroupOrRepoType
	Unknown
)

the target type values

View Source
const (
	GroupToGroup = iota
	GroupsToGroup
	RepositoryToRepository
	RepositoriesToGroup
	Invalid
)

Move type values

Variables

This section is empty.

Functions

func AddCommandFactory

func AddCommandFactory() (cli.Command, error)

AddCommandFactory generates the object of AddCommand.

func BuildCommandFactoryMap

func BuildCommandFactoryMap() map[string]cli.CommandFactory

BuildCommandFactoryMap builds a map of CommandFactories of rrh commands.

func CloneCommandFactory

func CloneCommandFactory() (cli.Command, error)

CloneCommandFactory returns an instance of the CloneCommand.

func ConfigCommandFactory

func ConfigCommandFactory() (cli.Command, error)

ConfigCommandFactory returns an instance of the ConfigCommand.

func ExportCommandFactory

func ExportCommandFactory() (cli.Command, error)

ExportCommandFactory generate the command struct.

func FetchAllCommandFactory

func FetchAllCommandFactory() (cli.Command, error)

FetchAllCommandFactory returns an instance of the FetchAllCommand.

func FetchCommandFactory

func FetchCommandFactory() (cli.Command, error)

FetchCommandFactory returns an instance of command.

func GenerateDefaultHelp

func GenerateDefaultHelp() string

GenerateDefaultHelp generates the help message string.

func GroupCommandFactory

func GroupCommandFactory() (cli.Command, error)

GroupCommandFactory returns an instance of command.

func HelpCommandFactory

func HelpCommandFactory() (cli.Command, error)

HelpCommandFactory returns an instance of the HelpCommand.

func ImportCommandFactory

func ImportCommandFactory() (cli.Command, error)

ImportCommandFactory generate the command struct.

func ListCommandFactory

func ListCommandFactory() (cli.Command, error)

ListCommandFactory returns an instance of the ListCommand.

func MoveCommandFactory

func MoveCommandFactory() (cli.Command, error)

MoveCommandFactory returns an instance of the MoveCommand.

func OpenCommandFactory added in v1.2.0

func OpenCommandFactory() (cli.Command, error)

OpenCommandFactory generates the object of AddCommand.

func PruneCommandFactory

func PruneCommandFactory() (cli.Command, error)

PruneCommandFactory returns an instance of the PruneCommand.

func RemoveCommandFactory

func RemoveCommandFactory() (cli.Command, error)

RemoveCommandFactory returns an instance of the RemoveCommand.

func RepositoryCommandFactory

func RepositoryCommandFactory() (cli.Command, error)

RepositoryCommandFactory returns an instance of the PruneCommand.

func StatusCommandFactory

func StatusCommandFactory() (cli.Command, error)

StatusCommandFactory returns an instance of the StatusCommand.

func VersionCommandFactory

func VersionCommandFactory() (cli.Command, error)

VersionCommandFactory returns an instance of the VersionCommand.

Types

type AddCommand

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

AddCommand shows the subcommand of rrh.

func (*AddCommand) AddRepositoriesToGroup

func (add *AddCommand) AddRepositoriesToGroup(db *rrh.Database, opt *addOptions) []error

AddRepositoriesToGroup registers the given repositories to the specified group.

func (*AddCommand) Help

func (add *AddCommand) Help() string

Help function shows the help message.

func (*AddCommand) Run

func (add *AddCommand) Run(args []string) int

Run function performs the command.

func (*AddCommand) Synopsis

func (add *AddCommand) Synopsis() string

Synopsis returns the simple help message of the command.

type CloneCommand

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

CloneCommand represents a command.

func (*CloneCommand) DoClone

func (clone *CloneCommand) DoClone(db *rrh.Database, arguments []string) (int, []error)

DoClone performs `git clone` command and register the cloned repositories to RRH database.

func (*CloneCommand) Help

func (clone *CloneCommand) Help() string

Help function shows the help message.

func (*CloneCommand) Run

func (clone *CloneCommand) Run(args []string) int

Run performs the command.

func (*CloneCommand) Synopsis

func (clone *CloneCommand) Synopsis() string

Synopsis returns the help message of the command.

type ConfigCommand

type ConfigCommand struct{}

ConfigCommand represents a command.

Example
os.Setenv(rrh.ConfigPath, "../testdata/config.json")
os.Setenv(rrh.Home, "../testdata/")
os.Setenv(rrh.DatabasePath, "${RRH_HOME}/test_db.json")
var command, _ = ConfigCommandFactory()
command.Run([]string{}) // the output of no arguments are same as list subcommand.
Output:
RRH_AUTO_CREATE_GROUP: true (config_file)
RRH_AUTO_DELETE_GROUP: false (config_file)
RRH_CLONE_DESTINATION: . (default)
RRH_COLOR: repository:fg=red+group:fg=magenta+label:op=bold+configValue:fg=green (default)
RRH_CONFIG_PATH: ../testdata/config.json (environment)
RRH_DATABASE_PATH: ../testdata/test_db.json (environment)
RRH_DEFAULT_GROUP_NAME: no-group (default)
RRH_ENABLE_COLORIZED: false (default)
RRH_HOME: ../testdata/ (environment)
RRH_ON_ERROR: WARN (default)
RRH_SORT_ON_UPDATING: true (config_file)
RRH_TIME_FORMAT: relative (default)

func (*ConfigCommand) Help

func (config *ConfigCommand) Help() string

Help returns the help message.

func (*ConfigCommand) Run

func (config *ConfigCommand) Run(args []string) int

Run performs the command.

Example
os.Setenv(rrh.ConfigPath, "../testdata/config.json")
os.Setenv(rrh.Home, "../testdata/")
os.Setenv(rrh.DatabasePath, "${RRH_HOME}/database.json")
var command, _ = ConfigCommandFactory()
command.Run([]string{"list"}) // the output of no arguments are same as list subcommand.
Output:
RRH_AUTO_CREATE_GROUP: true (config_file)
RRH_AUTO_DELETE_GROUP: false (config_file)
RRH_CLONE_DESTINATION: . (default)
RRH_COLOR: repository:fg=red+group:fg=magenta+label:op=bold+configValue:fg=green (default)
RRH_CONFIG_PATH: ../testdata/config.json (environment)
RRH_DATABASE_PATH: ../testdata/database.json (environment)
RRH_DEFAULT_GROUP_NAME: no-group (default)
RRH_ENABLE_COLORIZED: false (default)
RRH_HOME: ../testdata/ (environment)
RRH_ON_ERROR: WARN (default)
RRH_SORT_ON_UPDATING: true (config_file)
RRH_TIME_FORMAT: relative (default)

func (*ConfigCommand) Synopsis

func (config *ConfigCommand) Synopsis() string

Synopsis returns the help message of the command.

type ExportCommand

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

ExportCommand represents a command.

func (*ExportCommand) Help

func (export *ExportCommand) Help() string

Help returns the help message of the command.

func (*ExportCommand) Run

func (export *ExportCommand) Run(args []string) int

Run peforms the command.

func (*ExportCommand) Synopsis

func (export *ExportCommand) Synopsis() string

Synopsis returns the simple help message of the command.

type FetchAllCommand

type FetchAllCommand struct{}

FetchAllCommand represents a command.

func (*FetchAllCommand) Help

func (fetchAll *FetchAllCommand) Help() string

Help returns the help message.

func (*FetchAllCommand) Run

func (fetchAll *FetchAllCommand) Run(args []string) int

Run performs the command.

func (*FetchAllCommand) Synopsis

func (fetchAll *FetchAllCommand) Synopsis() string

Synopsis returns the help message of the command.

type FetchCommand

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

FetchCommand represents a command.

func (*FetchCommand) DoFetch

func (fetch *FetchCommand) DoFetch(repo *rrh.Repository, relation *rrh.Relation, progress *Progress) error

DoFetch executes fetch operation of git. Currently, fetch is conducted by the system call. Ideally, fetch is performed by using go-git.

func (*FetchCommand) FetchRepository

func (fetch *FetchCommand) FetchRepository(db *rrh.Database, relation *rrh.Relation, progress *Progress) error

FetchRepository execute `git fetch` on the given repository.

func (*FetchCommand) Help

func (fetch *FetchCommand) Help() string

Help returns the help message of the command.

func (*FetchCommand) Run

func (fetch *FetchCommand) Run(args []string) int

Run performs the command.

func (*FetchCommand) Synopsis

func (fetch *FetchCommand) Synopsis() string

Synopsis returns the help message of the command.

type GroupCommand

type GroupCommand struct{}

GroupCommand represents a command.

func (*GroupCommand) Help

func (group *GroupCommand) Help() string

Help returns the help message of the command.

func (*GroupCommand) Run

func (group *GroupCommand) Run(args []string) int

Run peforms the command.

Example
var dbFile = rrh.Rollback("../testdata/test_db.json", "../testdata/config.json", func(config *rrh.Config, db *rrh.Database) {
	var gc, _ = GroupCommandFactory()
	gc.Run([]string{"list"})
})
defer os.Remove(dbFile)
Output:
group1,1 repository
group2,0 repositories
group3,1 repository

func (*GroupCommand) Synopsis

func (group *GroupCommand) Synopsis() string

Synopsis returns the help message of the command.

type HelpCommand

type HelpCommand struct {
}

HelpCommand shows the struct for help command.

func (*HelpCommand) Help

func (help *HelpCommand) Help() string

Help returns the help message.

func (*HelpCommand) Run

func (help *HelpCommand) Run(args []string) int

Run performs the command.

func (*HelpCommand) Synopsis

func (help *HelpCommand) Synopsis() string

Synopsis returns the help message of the command.

type ImportCommand

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

ImportCommand represents a command.

func (*ImportCommand) Help

func (command *ImportCommand) Help() string

Help returns the help message of the command.

func (*ImportCommand) Run

func (command *ImportCommand) Run(args []string) int

Run peforms the command.

func (*ImportCommand) Synopsis

func (command *ImportCommand) Synopsis() string

Synopsis returns the simple help message of the command.

type ListCommand

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

ListCommand represents a command.

Example
var dbFile = rrh.Rollback("../testdata/database.json", "../testdata/config.json", func(config *rrh.Config, oldDB *rrh.Database) {
	var list, _ = ListCommandFactory()
	list.Run([]string{})
})
defer os.Remove(dbFile)
Output:
no-group (2 repositories)
    rrh          ~/go/src/github.com/tamada/rrh
    helloworld   ../testdata/helloworld
1 group, 2 repositories

func (*ListCommand) FindResults

func (list *ListCommand) FindResults(db *rrh.Database) ([]Result, error)

FindResults returns the result list of list command.

func (*ListCommand) Help

func (list *ListCommand) Help() string

Help function shows the help message.

func (*ListCommand) Run

func (list *ListCommand) Run(args []string) int

Run performs the command.

Example
var dbFile = rrh.Rollback("../testdata/test_db.json", "../testdata/config.json", func(config *rrh.Config, oldDB *rrh.Database) {
	var list, _ = ListCommandFactory()
	list.Run([]string{"--desc", "--path"})
})
defer os.Remove(dbFile)
Output:
group1 (1 repository)
    Description  desc1
    repo1        path1
group2 (0 repositories)
    Description  desc2
group3 (1 repository)
3 groups, 2 repositories

func (*ListCommand) Synopsis

func (list *ListCommand) Synopsis() string

Synopsis returns the help message of the command.

type MoveCommand

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

MoveCommand represents a command.

func (*MoveCommand) Help

func (mv *MoveCommand) Help() string

Help function shows the help message.

func (*MoveCommand) Run

func (mv *MoveCommand) Run(args []string) int

Run performs the command.

func (*MoveCommand) Synopsis

func (mv *MoveCommand) Synopsis() string

Synopsis returns the help message of the command.

type OpenCommand added in v1.2.0

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

OpenCommand represents a command.

func (*OpenCommand) Help added in v1.2.0

func (open *OpenCommand) Help() string

Help function shows the help message.

func (*OpenCommand) Run added in v1.2.0

func (open *OpenCommand) Run(args []string) int

Run performs the command.

func (*OpenCommand) Synopsis added in v1.2.0

func (open *OpenCommand) Synopsis() string

Synopsis returns the simple help message of the command.

type Progress

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

Progress represents a fetching progress.

func NewProgress

func NewProgress(total int) *Progress

NewProgress genereate an instance of Progress. If the given value is negative value, this method treats the given value is 0.

func (*Progress) Increment

func (progress *Progress) Increment()

Increment adds 1 to the progress. However, if current value is equals to total, this method does nothing.

func (*Progress) String

func (progress *Progress) String() string

String returns the string representation of the progress.

type PruneCommand

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

PruneCommand represents a command.

func (*PruneCommand) Help

func (prune *PruneCommand) Help() string

Help function shows the help message.

func (*PruneCommand) Run

func (prune *PruneCommand) Run(args []string) int

Run performs the command.

Example
var dbFile = rrh.Rollback("../testdata/test_db.json", "../testdata/config.json", func(config *rrh.Config, db *rrh.Database) {
	var prune, _ = PruneCommandFactory()
	prune.Run([]string{})
})
defer os.Remove(dbFile)
Output:
Pruned 3 groups, 2 repositories

func (*PruneCommand) Synopsis

func (prune *PruneCommand) Synopsis() string

Synopsis returns the help message of the command.

type RemoveCommand

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

RemoveCommand represents a command.

func (*RemoveCommand) Help

func (rm *RemoveCommand) Help() string

Help returns the help message.

func (*RemoveCommand) Run

func (rm *RemoveCommand) Run(args []string) int

Run performs the command.

Example
var dbFile = rrh.Rollback("../testdata/test_db.json", "../testdata/config.json", func(config *rrh.Config, oldDB *rrh.Database) {
	var rm, _ = RemoveCommandFactory()
	rm.Run([]string{"-v", "group2", "repo1"})
})
defer os.Remove(dbFile)
Output:
group2: group removed
repo1: repository removed

func (*RemoveCommand) Synopsis

func (rm *RemoveCommand) Synopsis() string

Synopsis returns the help message of the command.

type Repo

type Repo struct {
	Name    string
	Path    string
	Remotes []rrh.Remote
}

Repo represents the result for showing of repositories.

type RepositoryCommand

type RepositoryCommand struct{}

RepositoryCommand represents a command.

func (*RepositoryCommand) Help

func (repository *RepositoryCommand) Help() string

Help function shows the help message.

func (*RepositoryCommand) Run

func (repository *RepositoryCommand) Run(args []string) int

Run performs the command.

func (*RepositoryCommand) Synopsis

func (repository *RepositoryCommand) Synopsis() string

Synopsis returns the help message of the command.

type Result

type Result struct {
	GroupName   string
	Description string
	OmitList    bool
	Repos       []Repo
}

Result represents the result for showing.

type StatusCommand

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

StatusCommand represents a command.

func (*StatusCommand) Help

func (status *StatusCommand) Help() string

Help returns the help message for the user.

func (*StatusCommand) Run

func (status *StatusCommand) Run(args []string) int

Run performs the command.

func (*StatusCommand) Synopsis

func (status *StatusCommand) Synopsis() string

Synopsis returns the help message of the command.

type VersionCommand

type VersionCommand struct {
}

VersionCommand shows the struct for version command.

func (*VersionCommand) Help

func (version *VersionCommand) Help() string

Help returns the help message.

func (*VersionCommand) Run

func (version *VersionCommand) Run(args []string) int

Run performs the command.

Example
var command, _ = VersionCommandFactory()
command.Run([]string{})
Output:
rrh version 1.2.0

func (*VersionCommand) Synopsis

func (version *VersionCommand) Synopsis() string

Synopsis returns the help message of the command.

Jump to

Keyboard shortcuts

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