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

Support multiple files from the CLI (support dir globs) #109

Open
schneems opened this issue Nov 7, 2021 · 1 comment
Open

Support multiple files from the CLI (support dir globs) #109

schneems opened this issue Nov 7, 2021 · 1 comment

Comments

@schneems
Copy link
Collaborator

schneems commented Nov 7, 2021

Problem

To run this against multiple files developers want to run:

$ dead_end **/*.rb

This doesn't work today due to terminal globbing, which we don't yet support. What's happening when that command is run is that info isn't coming to dead_end. Your shell is expanding the input to be all files:

$ echo **/*.rb
lib/dead_end.rb lib/dead_end/around_block_scan.rb lib/dead_end/auto.rb lib/dead_end/block_expand.rb lib/dead_end/capture_code_context.rb lib/dead_end/clean_document.rb lib/dead_end/cli.rb lib/dead_end/code_block.rb lib/dead_end/code_frontier.rb lib/dead_end/code_line.rb lib/dead_end/code_search.rb lib/dead_end/display_code_with_line_numbers.rb lib/dead_end/display_invalid_blocks.rb lib/dead_end/explain_syntax.rb lib/dead_end/insertion_sort.rb lib/dead_end/left_right_lex_count.rb lib/dead_end/lex_all.rb lib/dead_end/lex_value.rb lib/dead_end/parse_blocks_from_indent_line.rb lib/dead_end/ripper_errors.rb lib/dead_end/version.rb spec/integration/dead_end_spec.rb spec/integration/exe_cli_spec.rb spec/integration/ruby_command_line_spec.rb spec/spec_helper.rb spec/unit/around_block_scan_spec.rb spec/unit/block_expand_spec.rb spec/unit/capture_code_context_spec.rb spec/unit/clean_document_spec.rb spec/unit/cli_spec.rb spec/unit/code_block_spec.rb spec/unit/code_frontier_spec.rb spec/unit/code_line_spec.rb spec/unit/code_search_spec.rb spec/unit/display_invalid_blocks_spec.rb spec/unit/explain_syntax_spec.rb spec/unit/insertion_sort_spec.rb spec/unit/lex_all_spec.rb

So what's really happening when you run that dead_end **/*.rb command (I think) is that we're only looking at the first file in the list. i.e. calling this:

$ dead_end **/*.rb

Is functionally the same as calling:

$ dead_end lib/dead_end.rb # based on the file output from above

That's the problem.

Solution

The fix would be pretty easy, which would be to look at all inputs rather than just the first one. Essentially change this in the CLI to loop over all args, https://github.com/zombocom/dead_end/blob/e8eb54c651bfa196fc933f76def5d811bb5d57dc/lib/dead_end/cli.rb#L43-L55

@schneems schneems changed the title Support terminal globs Support multiple files from the CLI (support dir globs) Nov 7, 2021
@bkuhlmann
Copy link

bkuhlmann commented Nov 7, 2021

In case it helps, you have to be careful with quotes too. Here's an example:

2021-11-07_13-52-57-iTerm2

So avoid the quotes. I stumbled upon this when adding this as Git Hook pre-commit check but have it working now:

dead_end

schneems added a commit that referenced this issue Nov 9, 2021
Close #109

This change allows multiple files to be passed into the CLI with one call:


```
$ ./exe/dead_end **/*.rb
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
```
schneems added a commit that referenced this issue Nov 9, 2021
Close #109

This change allows multiple files to be passed into the CLI with one call:


```
$ ./exe/dead_end **/*.rb
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
```
schneems added a commit that referenced this issue Nov 9, 2021
Close #109

This change allows multiple files to be passed into the CLI with one call:

```
$ ./exe/dead_end **/*.rb
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
Syntax OK
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants