syntax_suggest icon indicating copy to clipboard operation
syntax_suggest copied to clipboard

Support multiple files from the CLI (support dir globs)

Open schneems opened this issue 3 years ago • 1 comments

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 avatar Nov 07 '21 19:11 schneems

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

bkuhlmann avatar Nov 07 '21 20:11 bkuhlmann