Repository: aws-cloudformation/cfn-lint

Issue:
Autodetect template files
### Is this feature request related to a new rule or cfn-lint capabilities?

rules

### Describe the feature you'd like to request

If a template file [AWSTemplateFormatVersion: '2010-09-09'] is run through cfn-lint as a normal file, it results in
E1001: 'Resources' is a required property (despite having a Resources: section)

But if the same filename is given after a -t commandline switch, the file is processed normally.

So why not at least add an option to autodetect template files ?

### Describe the solution you'd like

A commandline option (eg --detect_template) to cause input files from the filename list  to be checked for the "AWSTemplateFormatVersion: '2010-09-09' property, and switch into template mode if so.


### Additional context

_No response_

### Is this something that you'd be interested in working on?

- [ ] 👋 I may be able to implement this feature request

### Would this feature include a breaking change?

- [ ] ⚠️ This feature might incur a breaking change

Hints from issue comments:
@mbarneyjr: I'm experiencing an issue where `cfn-lint -t path/to/template.yml` works, but `cfn-lint` with the following config does not work:
```yml
templates:
  - path/to/template.yml
```

```sh
$ cfn-lint -t path/to/template.yml
$ cfn-lint
E1001 'Resources' is a required property
None:1:1
```@kddejong: Looking into it.@gastonsponer: Same as @mbarneyjr 

E1001 'Resources' is a required property
None:1:1

Error: Process completed with exit code 2.@kddejong: This should undo change #4138 that created this error.  The better long term solution will be to see if any data is in stdin.  I'm going to do that change later as its going to take some work to implement correctly. 

Solution patch:
diff --git a/src/cfnlint/config.py b/src/cfnlint/config.py
index 005cedfaa..0dff8066e 100644
--- a/src/cfnlint/config.py
+++ b/src/cfnlint/config.py
@@ -777,8 +777,9 @@ class ConfigMixIn(TemplateArgs, CliArgs, ConfigFileArgs):
             filenames = cli_alt_args
         elif cli_args:
             filenames = cli_args
-        elif not sys.stdin.isatty():
-            return []
+        # elif not sys.stdin.isatty():
+        #    if (select.select([sys.stdin], [], [], 0.0)[0]):
+        #        return []
         elif file_args:
             filenames = file_args
         else:


Test patch:
diff --git a/test/unit/module/runner/test_cli.py b/test/unit/module/runner/test_cli.py
index 7d843dafb..8d511584b 100644
--- a/test/unit/module/runner/test_cli.py
+++ b/test/unit/module/runner/test_cli.py
@@ -79,7 +79,8 @@ class TestCli(BaseTestCase):
 
         self.assertEqual(e.exception.code, 1)
         mock_print_help.assert_called_once()
-        self.assertEqual(mock_isatty.call_count, 2)
+        mock_isatty.assert_called_once()
+        # self.assertEqual(mock_isatty.call_count, 2)
 
     def test_bad_regions(self):
         config = ConfigMixIn(