Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd: Deprecate CLI arguments #1687

Merged
merged 1 commit into from
Feb 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cmd/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,26 @@ func (cli *CLI) Run(args []string) int {

switch {
case opts.Version:
if len(args) > 1 {
fmt.Fprintln(cli.errStream, `WARNING: Arguments are not used in version mode and will error in a future version. Use --chdir instead.`)
}
return cli.printVersion(opts)
case opts.Init:
if len(args) > 1 {
fmt.Fprintln(cli.errStream, `WARNING: Arguments are not used in init mode and will error in a future version. Use --chdir instead.`)
}
return cli.init(opts)
case opts.Langserver:
if len(args) > 1 {
fmt.Fprintln(cli.errStream, `WARNING: Arguments are not used in language server mode and will error in a future version.`)
}
return cli.startLanguageServer(opts)
case opts.ActAsBundledPlugin:
return cli.actAsBundledPlugin()
default:
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.`)
}
return cli.inspect(opts, args)
}
}
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