git-bug/bridge/core/interfaces.go
Sascha 1939949fcd
CLI: Add non-interactive option to interactive commands (#651)
* Add option to skip the AvatarURL input request

Using an empty string for the avatar cli flag e.g. `git-bug user create
-a ""` will still result in a prompt. As the avatar URL is an optional
option, it should be possible to skip asking for it entirely.
Otherwise automated user creation via a script must make use of pipe hacks.

* Add global --non-interactive cmdline option

* Replace --skipAvatar for --non-interactive option

* Cmd BugAdd: respect non-interactive option

* Cmd bridge configure: respect non-interactive opt

* Cmd CommentAdd: respect non-interactive option

* Cmd CommentEdit: respect non-interactive option

* Cmd TermUI: respect non-interactive option

* Cmd TitleEdit: respect non-interactive option

* Remove global non-interactive option

* Cmd UserCreate: Use local non-interactive option

* Cmd BugAdd: Use local non-interactive option

* Cmd BridgeConfigure: Use local non-interactive option

* Cmd CommentAdd: Use local non-interactive option

* Cmd CommentEdit: Use local non-interactive option

* Cmd TermUI: Drop non-interactive option

It should be obviouse that the termui is an interactive command.

* Cmd TitleEdit: Use local non-interactive option

* Update docs

* Bridge GitHub: respect non-interactive option

* Bridge GitLab: respect non-interactive option

* Bridge Jira: respect non-interactive and token opt

* Fix failing compilation

* Bridge launchpad: respect non-interactive option

* bridge: isNonInteractive --> interactive

Co-authored-by: Michael Muré <batolettre@gmail.com>
2021-05-09 11:14:45 +02:00

47 lines
1.4 KiB
Go

package core
import (
"context"
"time"
"github.com/MichaelMure/git-bug/cache"
)
type Configuration map[string]string
type BridgeImpl interface {
// Target return the target of the bridge (e.g.: "github")
Target() string
// NewImporter return an Importer implementation if the import is supported
NewImporter() Importer
// NewExporter return an Exporter implementation if the export is supported
NewExporter() Exporter
// Configure handle the user interaction and return a key/value configuration
// for future use.
Configure(repo *cache.RepoCache, params BridgeParams, interactive bool) (Configuration, error)
// The set of the BridgeParams fields supported
ValidParams() map[string]interface{}
// ValidateConfig check the configuration for error
ValidateConfig(conf Configuration) error
// LoginMetaKey return the metadata key used to store the remote bug-tracker login
// on the user identity. The corresponding value is used to match identities and
// credentials.
LoginMetaKey() string
}
type Importer interface {
Init(ctx context.Context, repo *cache.RepoCache, conf Configuration) error
ImportAll(ctx context.Context, repo *cache.RepoCache, since time.Time) (<-chan ImportResult, error)
}
type Exporter interface {
Init(ctx context.Context, repo *cache.RepoCache, conf Configuration) error
ExportAll(ctx context.Context, repo *cache.RepoCache, since time.Time) (<-chan ExportResult, error)
}