Skip to content

Commit

Permalink
cmd: Deprecate CLI arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
wata727 committed Feb 14, 2023
1 parent 602fa73 commit ac52d17
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ func (cli *CLI) Run(args []string) int {
cli.formatter.Print(tflint.Issues{}, fmt.Errorf("Failed to parse CLI options; %w", err), map[string][]byte{})
return ExitCodeError
}
if len(args) > 1 {
fmt.Fprintln(cli.errStream, `WARNING: "tflint FILE/DIR" is deprecated and will error in a future version. Use --chdir or --filter instead.`)
}

switch {
case opts.Version:
Expand Down
5 changes: 5 additions & 0 deletions integrationtest/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ func TestIntegration(t *testing.T) {
dir: "multiple_files",
status: cmd.ExitCodeOK,
stdout: "", // main.tf is ignored
stderr: `WARNING: "tflint FILE/DIR" is deprecated and will error in a future version. Use --chdir or --filter instead.`,
},
{
name: "file not found",
Expand All @@ -266,20 +267,23 @@ func TestIntegration(t *testing.T) {
status: cmd.ExitCodeIssuesFound,
// main.tf is not ignored
stdout: fmt.Sprintf("%s (aws_instance_example_type)", color.New(color.Bold).Sprint("instance type is t2.micro")),
stderr: `WARNING: "tflint FILE/DIR" is deprecated and will error in a future version. Use --chdir or --filter instead.`,
},
{
name: "directory argument",
command: "./tflint subdir",
dir: "multiple_files",
status: cmd.ExitCodeIssuesFound,
stdout: fmt.Sprintf("%s (aws_instance_example_type)", color.New(color.Bold).Sprint("instance type is m5.2xlarge")),
stderr: `WARNING: "tflint FILE/DIR" is deprecated and will error in a future version. Use --chdir or --filter instead.`,
},
{
name: "file under the directory",
command: fmt.Sprintf("./tflint %s", filepath.Join("subdir", "main.tf")),
dir: "multiple_files",
status: cmd.ExitCodeIssuesFound,
stdout: fmt.Sprintf("%s (aws_instance_example_type)", color.New(color.Bold).Sprint("instance type is m5.2xlarge")),
stderr: `WARNING: "tflint FILE/DIR" is deprecated and will error in a future version. Use --chdir or --filter instead.`,
},
{
name: "multiple directories",
Expand Down Expand Up @@ -344,6 +348,7 @@ func TestIntegration(t *testing.T) {
dir: "chdir",
status: cmd.ExitCodeIssuesFound,
stdout: fmt.Sprintf("%s (aws_instance_example_type)", color.New(color.Bold).Sprint("instance type is m5.2xlarge")),
stderr: `WARNING: "tflint FILE/DIR" is deprecated and will error in a future version. Use --chdir or --filter instead.`,
},
{
name: "--chdir and directory argument",
Expand Down

0 comments on commit ac52d17

Please sign in to comment.