Skip to content

ABAlosaimi/DiFi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DiFi

reuse your code without OOP stuff

DiFi is a CLI (command line interface) tool that enables you to reuse your previous written feature in a brown/new project(s) by cleaning up project-related details (like package statements) and write the cleaned content to your project directory.

Features

  • Open and read any file
  • Filter file content by skipping a specified number of initial lines don't needed
  • Write filtered content to a target directory with the same filename

Note: you should check about permissions on read & write to the file you are trying to reuse.

Project Structure

DiFi/
├── cmd/
│   └── main/
│       └── main.go           # Entry point of the application
├── internal/
│   └── combiner/
│       └── projectCombiner.go # Core logic
├── go.mod                     # Go module definition
└── README.md                 

Local installation

  1. Clone the repo:
git clone https://github.com/ABAlosaimi/DiFi
  1. Build the project:
go build -o difi ./cmd/main

Usage

Run the compiled binary or use go run:

go run main.go <filePath> <filteringStartLineNum> <projectDir>

Note: You must be in the main directory

Arguments

  • filePath: Absolute path to the file you want to filter
  • filteringStartLineNum: Number of lines to skip from the beginning of the file (0-indexed)
  • projectDir: The target directory where the filtered file will be written

Example

go run main.go "/path/to/input.txt" 5 "/path/to/output/dir"

The workflow will be:

  1. Open /path/to/input.txt
  2. Skip the first 5 lines
  3. Write the remaining content to /path/to/output/dir/input.txt

Use Cases

1. Removing Headers from Data Files

Skip header rows in CSV or text files before processing:

difi data.csv 1 ./processed

2. Extracting Content from Templates

Remove boilerplate or template headers from code files:

difi template.go 10 ./src

3. Cleaning Log Files

Remove initial metadata or timestamps from log files:

difi app.log 3 ./clean-logs

How It Works

DiFi operates in three main steps:

  1. Open: Reads the source file from the specified path
  2. Filter: Scans the file line-by-line and skips the specified number of initial lines
  3. Write: Creates a new file in the target directory with the filtered content

Requirements to run locally

  • Go 1.16 or higher

Author

Claude code, reviewed by eng.Abdulrahman F. Alosaimi

About

A CLI tool for code reuse without OOP need & path errors

Topics

Resources

Stars

Watchers

Forks

Contributors