gogh

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrProjectNotFound is the error will be raised when a project is not found.
	ErrProjectNotFound = errors.New("project not found")
	// ErrProjectAlreadyExists is the error will be raised when a project already exists.
	ErrProjectAlreadyExists = errors.New("project already exists")
)

Functions

func CheckRepoHost added in v0.4.0

func CheckRepoHost(ctx GitHubContext, repo *Repo) error

CheckRepoHost that repo is in supported host

func FindProjectPath added in v0.4.0

func FindProjectPath(ctx Context, repo *Repo) (string, error)

FindProjectPath willl get a project (local repository) path from remote repository URL

func Query added in v0.3.0

func Query(ctx Context, query string, walk Walker, callback WalkFunc) error

Query searches projects (local repositories) with specified walker

func SupportedHost added in v1.0.0

func SupportedHost(ctx GitHubContext, host string) error

SupportedHost that repo is in supported host

func ValidateContext added in v1.0.0

func ValidateContext(ctx Context) error

func ValidateLogLevel added in v1.0.0

func ValidateLogLevel(level string) error

func ValidateName added in v0.5.6

func ValidateName(name string) error

func ValidateOwner added in v0.5.6

func ValidateOwner(owner string) error

func ValidateRoot added in v1.0.0

func ValidateRoot(root string) (string, error)

func ValidateRoots added in v1.0.0

func ValidateRoots(roots []string) error

func Walk added in v0.1.0

func Walk(ctx Context, callback WalkFunc) error

Walk thorugh projects (local repositories) in gogh.root directories

func WalkInPrimary added in v0.2.0

func WalkInPrimary(ctx Context, callback WalkFunc) error

WalkInPrimary thorugh projects (local repositories) in the first gogh.root directory

Types

type Context added in v0.1.0

type Context interface {
	context.Context
	IOContext
	GitHubContext
	LogContext
	Root() []string
	PrimaryRoot() string
}

Context holds configurations and environments

type GitHubContext added in v1.3.1

type GitHubContext interface {
	GitHubUser() string
	GitHubToken() string
	GitHubHost() string
}

GitHubContext holds configurations and environments for GitHub access.

type IOContext added in v1.3.1

type IOContext interface {
	Stdin() io.Reader
	Stdout() io.Writer
	Stderr() io.Writer
}

IOContext holds configurations and environments for I/O.

type LogContext added in v1.3.1

type LogContext interface {
	LogLevel() string
	LogFlags() int // log.Lxxx flags
	LogDate() bool
	LogTime() bool
	LogMicroSeconds() bool
	LogLongFile() bool
	LogShortFile() bool
	LogUTC() bool
}

GitHubContext holds configurations and environments for logging.

type Project added in v0.4.0

type Project struct {
	FullPath  string
	RelPath   string
	PathParts []string
	Exists    bool
}

Project repository specifier

func FindOrNewProject added in v0.5.8

func FindOrNewProject(ctx Context, repo *Repo) (*Project, error)

FindOrNewProject will find a project (local repository) that matches exactly or create new one.

func FindOrNewProjectInPrimary added in v1.0.0

func FindOrNewProjectInPrimary(ctx Context, repo *Repo) (*Project, error)

FindOrNewProjectInPrimary will find a project (local repository) that matches exactly or create new one.

func FindProject added in v0.4.0

func FindProject(ctx Context, repo *Repo) (*Project, error)

FindProject will find a project (local repository) that matches exactly.

func FindProjectInPrimary added in v1.0.0

func FindProjectInPrimary(ctx Context, repo *Repo) (*Project, error)

FindProjectInPrimary will find a project (local repository) that matches exactly.

func NewProject added in v0.4.0

func NewProject(ctx Context, repo *Repo) (*Project, error)

NewProject creates a project (local repository)

func (*Project) IsInPrimaryRoot added in v0.4.0

func (p *Project) IsInPrimaryRoot(ctx Context) bool

IsInPrimaryRoot check which the repository is in primary root directory for gogh

func (*Project) Subpaths added in v0.4.0

func (p *Project) Subpaths() []string

Subpaths returns lists of tail parts of relative path from the root directory (shortest first) for example, {"gogh", "kyoh86/gogh", "github.com/kyoh86/gogh"} for $root/github.com/kyoh86/gogh.

type ProjectListFormatter added in v0.4.0

type ProjectListFormatter interface {
	Add(*Project)
	Len() int
	PrintAll(io.Writer, string) error
	// contains filtered or unexported methods
}

ProjectListFormatter holds project list to print them.

func CustomFormatter added in v1.3.0

func CustomFormatter(format string) (ProjectListFormatter, error)

func FullPathFormatter added in v0.2.0

func FullPathFormatter() ProjectListFormatter

FullPathFormatter prints each full-path of the project.

func RelPathFormatter added in v0.2.0

func RelPathFormatter() ProjectListFormatter

RelPathFormatter prints each relative-path of the project

func ShortFormatter added in v0.2.0

func ShortFormatter() ProjectListFormatter

ShortFormatter prints each project as short as possible.

func URLFormatter added in v0.5.7

func URLFormatter() ProjectListFormatter

URLFormatter prints each project as url.

type ProjectShared added in v0.4.0

type ProjectShared string

ProjectShared notices file shared flag like group, all, everybody, 0766.

func (*ProjectShared) Set added in v0.4.0

func (s *ProjectShared) Set(text string) error

Set text as ProjectShared

func (ProjectShared) String added in v0.4.0

func (s ProjectShared) String() string

type Repo added in v0.4.0

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

Repo specifies a repository in the GitHub

func ParseProject added in v1.1.0

func ParseProject(p *Project) (*Repo, error)

ParseProject parses a repo-name for a repository in the GitHub

func ParseRepo added in v0.4.0

func ParseRepo(rawRepo string) (*Repo, error)

ParseRepo parses a repo-name for a repository in the GitHub

func (*Repo) FullName added in v0.5.5

func (r *Repo) FullName(ctx GitHubContext) string

FullName returns a repository identifier that is formed like {Owner/Name}

func (*Repo) Host added in v0.4.0

func (r *Repo) Host(ctx GitHubContext) string

Host returns host of the repository

func (*Repo) IsPublic added in v1.1.0

func (r *Repo) IsPublic(ctx GitHubContext) (bool, error)

Check if a GitHub repo is public (we can access the repo without token or auth)

func (*Repo) Match added in v1.0.4

func (r *Repo) Match(p *Project) bool

Match with project.

func (*Repo) Name added in v0.4.0

func (r *Repo) Name(_ GitHubContext) string

Name returns a name of the repository

func (*Repo) Owner added in v0.4.0

func (r *Repo) Owner(ctx GitHubContext) string

Owner returns a user name of an owner of the repository

func (*Repo) RelPath added in v0.4.0

func (r *Repo) RelPath(ctx GitHubContext) string

RelPath get relative path from root directory

func (*Repo) Scheme added in v0.4.0

func (r *Repo) Scheme(_ GitHubContext) string

Scheme returns scheme of the repository

func (*Repo) Set added in v0.4.0

func (r *Repo) Set(rawRepo string) error

Set text as Repo

func (Repo) String added in v0.4.0

func (r Repo) String() string

func (*Repo) URL added in v0.4.0

func (r *Repo) URL(ctx GitHubContext, ssh bool) *url.URL

URL will get a URL for a repository

type Repos added in v0.4.0

type Repos []Repo

Repos is array of Repo

func (Repos) IsCumulative added in v0.4.0

func (r Repos) IsCumulative() bool

IsCumulative : 複数指定可能

func (*Repos) Set added in v0.4.0

func (r *Repos) Set(value string) error

Set will add a text to Repos as a Repo

func (Repos) String added in v0.4.0

func (r Repos) String() string

String : Stringに変換する

type WalkFunc added in v0.2.0

type WalkFunc func(*Project) error

WalkFunc is the type of the function called for each repository visited by Walk / WalkInPrimary

type Walker added in v0.2.0

type Walker func(Context, WalkFunc) error

Walker is the type of the function to visit each repository

Jump to

Keyboard shortcuts

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