Skip to content

spacepirate0001/File-tool

Repository files navigation

file-tool

A command-line tool for common file operations.

Latest Release CI/CD Quality Gate Status codecov Python Versions License Code style: black Security: bandit Imports: isort

Features

  • Create files (empty or with content)
  • Copy files
  • Combine two files into one
  • Delete files
  • Error handling and logging
  • Complete test coverage

Project Structure

file-tool/
├── debian/
│   ├── control           # Package metadata
│   ├── copyright        # License information
│   └── changelog        # Version history
├── src/
│   ├── operations/
│   │   └── file_operations.py    # Core file operation implementations
│   ├── utils/
│   │   ├── exceptions.py         # Custom exceptions
│   │   └── helpers.py           # Utility functions
│   └── main.py                  # CLI application entry point
├── tests/
│   ├── conftest.py              # Test configurations and fixtures
│   ├── test_file_operations.py  # File operations tests
│   ├── test_helpers.py         # Utility function tests
│   └── test_main.py            # CLI interface tests
├── .dockerignore
├── .gitignore
├── Dockerfile
├── LICENSE
├── README.md
├── file-tool.spec
├── poetry.lock
├── pyproject.toml
├── sonar-project.properties
├── requirements.txt
└── requirements-dev.txt

Installation

Using Poetry

  1. Install Poetry:

    curl -sSL https://install.python-poetry.org | python3 -
  2. Verify Poetry Installation:

    poetry --version

    Should see

    Poetry (version 1.x.x)
  3. Clone and install:

    git clone https://github.com/spacepirate0001/file-tool.git
    cd file-tool
    poetry install --with dev

Using Prebuilt Executables

You can download the prebuilt standalone executable for Linux from the releases:

  1. Download the latest release:

    # Get the latest release
    LATEST_VERSION=$(curl -s https://api.github.com/repos/spacepirate0001/file-tool/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
    
    # Download the tarball
    wget https://github.com/spacepirate0001/file-tool/releases/download/${LATEST_VERSION}/file-tool-${LATEST_VERSION#v}-linux-x64.tar.gz
  2. Extract the tarball:

    tar -xzf file-tool-*-linux-x64.tar.gz
  3. Make sure file is executable:

    chmod +x file-tool
  4. Run the executable:

    ./file-tool

Using Docker

docker build -t file-tool .

Usage

After Installation

Once installed using Poetry, you can run commands directly:

file-tool [command] [options]

If using Executable:

./file-tool [command] [options]

If using Docker:

docker run file-tool [command] [options]

Available Commands

Create a file

Create an empty file:

file-tool create myfile.txt

Create a file with content:

file-tool create myfile.txt --content "Hello, World!"

Copy a file

file-tool copy source.txt destination.txt

Combine files

Combines two files into a new file:

file-tool combine first.txt second.txt output.txt

Delete a file

file-tool delete myfile.txt

Command Options

file-tool --help         # Show general help
file-tool create --help  # Show help for create command
file-tool copy --help    # Show help for copy command
file-tool combine --help # Show help for combine command
file-tool delete --help  # Show help for delete command

Development

Using Dev Containers (Recommended)

This project includes configuration for development using VS Code Dev Containers, which provides a consistent, isolated development environment.

Prerequisites

Setup

  1. Open the project in VS Code
  2. When prompted, click "Reopen in Container" or:
    • Press F1, select "Dev Containers: Reopen in Container"

The container will:

  • Set up a complete Python development environment
  • Install all dependencies
  • Configure VS Code with recommended extensions and settings
  • Make the file-tool command available

Features

  • Pre-configured Python development environment
  • Integrated testing and debugging
  • Code formatting and linting tools
  • Test coverage visualization
  • Consistent environment across different machines

Alternative: Local Development

If you prefer not to use Dev Containers, you can develop locally:

git clone https://github.com/spacepirate0001/file-tool.git
cd file-tool
poetry install

Testing

Run all tests:

poetry run pytest

Run tests with coverage:

poetry run pytest --cov=src

Code Quality

Format code:

poetry run black src tests

Sort imports:

poetry run isort src tests

Type checking:

poetry run mypy src

License

This project is licensed under the GNU Public License - see the LICENSE file for details.

About

A file manipulation CLI tool.

Resources

License

Stars

Watchers

Forks

Packages

No packages published