This is a command-line utility that can:
- Create an empty file or a file with provided text
- Copy a file
- Combine multiple files into a single file
- Delete a file
Ensure you have Python 3.8 or later installed.
python3 -m venv venv
. ./venv/bin/activate
pip3 install '.'
Ready to get started? With your virtual environment activated, run this to output help text:
file_handler
This will list commands you can use. Each command has its own help text. For example the create command has:
file_handler create --help
file_handler create --name="test1" --text="1\n"
file_handler create --name="test2" --text="2\n"
file_handler combine --input-file="test1" --input-file="test2" --output-file="test3"
file_handler copy --source="test1" --destination="test4"
file_handler delete --name="test1"
file_handler delete --name="test2"
file_handler delete --name="test3"
file_handler delete --name="test4"
Install the test code with:
pip3 install -e '.[test]'
Run the tests with:
python3 -m pytest
The tests use isolated_filesystem() which will automatically write and delete the files in a temporary directory. If you want the files to persist, you can switch to using isolated_filesystem(temp_dir='tmp') or similar. Be sure that the directory exists.
Each command has a corresponding test file in tests/.
Each command has a corresponding file in file_handler/commands/. The file name is used as the command name automatically. Docstrings are automatically included in command-line help text. Your best bet is to copy an existing file and modify it as needed to get started.
Some ideas for future development:
- Use https://pyinstaller.org/en/stable/ to make a real bin, could be neat?
- Set up automated CI using GitHub Actions?
- Use some of the fancy features in https://click.palletsprojects.com/en/stable/handling-files/#handling-files maybe?