diff --git a/cmd/config.go b/cmd/config.go index b8c7561..647cd43 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -76,18 +76,22 @@ var ( ) func init() { - homeDir, err := utils.Home() - if err != nil { - log.Fatal("Retrieve home dir failed") - } + if configValue != "" { + yamlConfigPath = configValue + } else { + homeDir, err := utils.Home() + if err != nil { + log.Fatal("Retrieve home dir failed") + } - dir := filepath.Join(homeDir, ".tea") - err = os.MkdirAll(dir, os.ModePerm) - if err != nil { - log.Fatal("Init tea config dir", dir, "failed") - } + dir := filepath.Join(homeDir, ".tea") + err = os.MkdirAll(dir, os.ModePerm) + if err != nil { + log.Fatal("Init tea config dir", dir, "failed") + } - yamlConfigPath = filepath.Join(dir, "tea.yml") + yamlConfigPath = filepath.Join(dir, "tea.yml") + } } func splitRepo(repoPath string) (string, string) { diff --git a/cmd/flags.go b/cmd/flags.go index 7d740d9..97ec1c9 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -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, }