Skip to content

Commit

Permalink
Merge pull request #895 from suzuki-shunsuke/feat/support-env
Browse files Browse the repository at this point in the history
feat: support passing some command line arguments via environment variables
  • Loading branch information
suzuki-shunsuke authored Apr 18, 2023
2 parents 0d223d2 + cf68d9b commit 882e936
Showing 1 changed file with 42 additions and 28 deletions.
70 changes: 42 additions & 28 deletions pkg/cmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,24 @@ func (runner *Runner) Run(ctx context.Context, args []string) error { //nolint:f
Action: runner.postAction,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "org",
Usage: "GitHub organization name",
Name: "org",
Usage: "GitHub organization name",
EnvVars: []string{"GITHUB_COMMENT_REPO_ORG", "GHCMT_REPO_ORG"},
},
&cli.StringFlag{
Name: "repo",
Usage: "GitHub repository name",
Name: "repo",
Usage: "GitHub repository name",
EnvVars: []string{"GITHUB_COMMENT_REPO_NAME", "GHCMT_REPO_NAME"},
},
&cli.StringFlag{
Name: "token",
Usage: "GitHub API token",
EnvVars: []string{"GITHUB_TOKEN", "GITHUB_ACCESS_TOKEN"},
},
&cli.StringFlag{
Name: "sha1",
Usage: "commit sha1",
Name: "sha1",
Usage: "commit sha1",
EnvVars: []string{"GITHUB_COMMENT_SHA1", "GHCMT_SHA1"},
},
&cli.StringFlag{
Name: "template",
Expand All @@ -63,12 +66,14 @@ func (runner *Runner) Run(ctx context.Context, args []string) error { //nolint:f
Value: "default",
},
&cli.StringFlag{
Name: "config",
Usage: "configuration file path",
Name: "config",
Usage: "configuration file path",
EnvVars: []string{"GITHUB_COMMENT_CONFIG", "GHCMT_CONFIG"},
},
&cli.IntFlag{
Name: "pr",
Usage: "GitHub pull request number",
Name: "pr",
Usage: "GitHub pull request number",
EnvVars: []string{"GITHUB_COMMENT_PR_NUMBER", "GHCMT_PR_NUMBER"},
},
&cli.StringSliceFlag{
Name: "var",
Expand Down Expand Up @@ -110,21 +115,24 @@ func (runner *Runner) Run(ctx context.Context, args []string) error { //nolint:f
Action: runner.execAction,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "org",
Usage: "GitHub organization name",
Name: "org",
Usage: "GitHub organization name",
EnvVars: []string{"GITHUB_COMMENT_REPO_ORG", "GHCMT_REPO_ORG"},
},
&cli.StringFlag{
Name: "repo",
Usage: "GitHub repository name",
Name: "repo",
Usage: "GitHub repository name",
EnvVars: []string{"GITHUB_COMMENT_REPO_NAME", "GHCMT_REPO_NAME"},
},
&cli.StringFlag{
Name: "token",
Usage: "GitHub API token",
EnvVars: []string{"GITHUB_TOKEN", "GITHUB_ACCESS_TOKEN"},
},
&cli.StringFlag{
Name: "sha1",
Usage: "commit sha1",
Name: "sha1",
Usage: "commit sha1",
EnvVars: []string{"GITHUB_COMMENT_SHA1", "GHCMT_SHA1"},
},
&cli.StringFlag{
Name: "template",
Expand All @@ -137,12 +145,14 @@ func (runner *Runner) Run(ctx context.Context, args []string) error { //nolint:f
Value: "default",
},
&cli.StringFlag{
Name: "config",
Usage: "configuration file path",
Name: "config",
Usage: "configuration file path",
EnvVars: []string{"GITHUB_COMMENT_CONFIG", "GHCMT_CONFIG"},
},
&cli.IntFlag{
Name: "pr",
Usage: "GitHub pull request number",
Name: "pr",
Usage: "GitHub pull request number",
EnvVars: []string{"GITHUB_COMMENT_PR_NUMBER", "GHCMT_PR_NUMBER"},
},
&cli.StringSliceFlag{
Name: "var",
Expand Down Expand Up @@ -180,21 +190,24 @@ func (runner *Runner) Run(ctx context.Context, args []string) error { //nolint:f
Action: runner.hideAction,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "org",
Usage: "GitHub organization name",
Name: "org",
Usage: "GitHub organization name",
EnvVars: []string{"GITHUB_COMMENT_REPO_ORG", "GHCMT_REPO_ORG"},
},
&cli.StringFlag{
Name: "repo",
Usage: "GitHub repository name",
Name: "repo",
Usage: "GitHub repository name",
EnvVars: []string{"GITHUB_COMMENT_REPO_NAME", "GHCMT_REPO_NAME"},
},
&cli.StringFlag{
Name: "token",
Usage: "GitHub API token",
EnvVars: []string{"GITHUB_TOKEN", "GITHUB_ACCESS_TOKEN"},
},
&cli.StringFlag{
Name: "config",
Usage: "configuration file path",
Name: "config",
Usage: "configuration file path",
EnvVars: []string{"GITHUB_COMMENT_CONFIG", "GHCMT_CONFIG"},
},
&cli.StringFlag{
Name: "condition",
Expand All @@ -207,8 +220,9 @@ func (runner *Runner) Run(ctx context.Context, args []string) error { //nolint:f
Value: "default",
},
&cli.IntFlag{
Name: "pr",
Usage: "GitHub pull request number",
Name: "pr",
Usage: "GitHub pull request number",
EnvVars: []string{"GITHUB_COMMENT_PR_NUMBER", "GHCMT_PR_NUMBER"},
},
&cli.StringFlag{
Name: "sha1",
Expand Down

0 comments on commit 882e936

Please sign in to comment.