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

Take multiple arguments for files and directories to include #2

Closed
simonw opened this issue Mar 22, 2024 · 5 comments
Closed

Take multiple arguments for files and directories to include #2

simonw opened this issue Mar 22, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@simonw
Copy link
Owner

simonw commented Mar 22, 2024

That way you could send just specific files like this:

files-to-prompt app.py utils.py
@simonw simonw added the enhancement New feature or request label Mar 22, 2024
@dipam7
Copy link
Contributor

dipam7 commented Mar 23, 2024

Do you want to accept multiple args for path? or add a new option like --files?

@simonw
Copy link
Owner Author

simonw commented Apr 8, 2024

cat files_to_prompt/cli.py | llm -m opus --system '
Modify this file. It should take multiple arguments in a variable called paths. Each of those argumets might be a path to a file or it might be a path to a directory - if any of the arguments do not correspoind to a file or directory it should raise a click error.

It should then do what it does already but for all files or files-recursively-contained-within-folders that are passed to it.

It should still obey the gitignore logic.'

https://gist.github.com/simonw/345f16a54f9e753852ea0af4bd7c2abc

@simonw
Copy link
Owner Author

simonw commented Apr 8, 2024

files-to-prompt files_to_prompt tests | llm -m opus --system \
   'rewrite the tests to cover the ability to pass multiple files and folders to the tool'

https://gist.github.com/simonw/c3b021f7b4f8b1e30b79f95210cc5702

files-to-prompt files_to_prompt tests | llm -m opus --system \
  'add one last test which tests .gitignore and include_hidden against an example that mixes single files and directories of files together in one invocation'

https://gist.github.com/simonw/a578bae9fe409cb29533ae28a348cb27

@simonw simonw closed this as completed in cc8473b Apr 8, 2024
@simonw
Copy link
Owner Author

simonw commented Apr 8, 2024

I decided to make that last test a bit easier to read.

symbex test_mixed_paths_with_options | llm -m opus --system \
  'rewrite this test so the filenames are more obvious, thinks like ignored_in_gitignore.txt'

llm -c 'add a last bit to that test for ["test_dir", "single_file.txt", "--ignore-gitignore", "--include-hidden"]'

https://gist.github.com/simonw/a637f3e244ef1330e657221bfa84dfae

@simonw
Copy link
Owner Author

simonw commented Apr 8, 2024

That test:

def test_mixed_paths_with_options(tmpdir):
runner = CliRunner()
with tmpdir.as_cwd():
os.makedirs("test_dir")
with open("test_dir/.gitignore", "w") as f:
f.write("ignored_in_gitignore.txt\n.hidden_ignored_in_gitignore.txt")
with open("test_dir/ignored_in_gitignore.txt", "w") as f:
f.write("This file should be ignored by .gitignore")
with open("test_dir/.hidden_ignored_in_gitignore.txt", "w") as f:
f.write("This hidden file should be ignored by .gitignore")
with open("test_dir/included.txt", "w") as f:
f.write("This file should be included")
with open("test_dir/.hidden_included.txt", "w") as f:
f.write("This hidden file should be included")
with open("single_file.txt", "w") as f:
f.write("Contents of single file")
result = runner.invoke(cli, ["test_dir", "single_file.txt"])
assert result.exit_code == 0
assert "test_dir/ignored_in_gitignore.txt" not in result.output
assert "test_dir/.hidden_ignored_in_gitignore.txt" not in result.output
assert "test_dir/included.txt" in result.output
assert "test_dir/.hidden_included.txt" not in result.output
assert "single_file.txt" in result.output
assert "Contents of single file" in result.output
result = runner.invoke(cli, ["test_dir", "single_file.txt", "--include-hidden"])
assert result.exit_code == 0
assert "test_dir/ignored_in_gitignore.txt" not in result.output
assert "test_dir/.hidden_ignored_in_gitignore.txt" not in result.output
assert "test_dir/included.txt" in result.output
assert "test_dir/.hidden_included.txt" in result.output
assert "single_file.txt" in result.output
assert "Contents of single file" in result.output
result = runner.invoke(
cli, ["test_dir", "single_file.txt", "--ignore-gitignore"]
)
assert result.exit_code == 0
assert "test_dir/ignored_in_gitignore.txt" in result.output
assert "test_dir/.hidden_ignored_in_gitignore.txt" not in result.output
assert "test_dir/included.txt" in result.output
assert "test_dir/.hidden_included.txt" not in result.output
assert "single_file.txt" in result.output
assert "Contents of single file" in result.output
result = runner.invoke(
cli,
["test_dir", "single_file.txt", "--ignore-gitignore", "--include-hidden"],
)
assert result.exit_code == 0
assert "test_dir/ignored_in_gitignore.txt" in result.output
assert "test_dir/.hidden_ignored_in_gitignore.txt" in result.output
assert "test_dir/included.txt" in result.output
assert "test_dir/.hidden_included.txt" in result.output
assert "single_file.txt" in result.output
assert "Contents of single file" in result.output

simonw added a commit that referenced this issue Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants