added --config option

Signed-off-by: Andreas Ulm <andreas.ulm@root360.de>
This commit is contained in:
Andreas Ulm 2019-05-09 10:42:52 +02:00
parent 4bd1e56a84
commit 17054a3bcf
2 changed files with 24 additions and 11 deletions

View File

@ -76,6 +76,9 @@ var (
)
func init() {
if configValue != "" {
yamlConfigPath = configValue
} else {
homeDir, err := utils.Home()
if err != nil {
log.Fatal("Retrieve home dir failed")
@ -89,6 +92,7 @@ func init() {
yamlConfigPath = filepath.Join(dir, "tea.yml")
}
}
func splitRepo(repoPath string) (string, string) {
p := strings.Split(repoPath, "/")

View File

@ -16,6 +16,7 @@ var (
loginValue string
repoValue string
outputValue string
configValue string
)
// LoginFlag provides flag to specify tea login profile
@ -35,7 +36,14 @@ var RepoFlag = cli.StringFlag{
// OutputFlag provides flag to specify output type
var OutputFlag = cli.StringFlag{
Name: "output, o",
Usage: "Indicate one repository, optional when inside a gitea repository",
Usage: "Specify output format. (csv, simple, table, tsv, yaml)",
Destination: &outputValue,
}
// ConfigFlag provides flag to specify output type
var ConfigFlag = cli.StringFlag{
Name: "config, c",
Usage: "Specify tea.yml path",
Destination: &outputValue,
}
@ -44,6 +52,7 @@ var OutputFlag = cli.StringFlag{
// subcommand to work around issue:
// https://github.com/urfave/cli/issues/585
var DefaultFlags = []cli.Flag{
ConfigFlag,
LoginFlag,
OutputFlag,
}