NAME
App::codefork - Worlds dumbest code forker
VERSION
version 1.000
SYNOPSIS
use App::codefork;
my $app = App::codefork->new(config => 'fork.conf');
# Collect changes without applying them
my $changes = $app->collect_changes;
# Preview as unified diff
print $app->generate_diff($changes);
# Apply when ready
$app->apply_changes($changes);
DESCRIPTION
App::codefork is a simple tool for forking code by performing systematic replacements in filenames and file contents across directory trees.
The workflow is diff-based and safe by design: changes are first collected and can be previewed as a unified diff before anything is modified on disk.
For the command-line interface, see codefork.
config
Path to the config file containing forking instructions. Required.
dir
Work directory to process. Defaults to current directory.
debug
Show debug information. Enabled via CODEFORK_DEBUG=1 environment variable.
mods
Parsed modification instructions from the config file.
collect_changes
my $changes = $app->collect_changes;
Recursively scans the work directory and computes all modifications without applying them. Returns an arrayref of change hashrefs with keys old_path, new_path, old_content, new_content.
generate_diff
my $diff = $app->generate_diff($changes);
Generates a unified diff string from the collected changes. If $changes is not passed, calls "collect_changes" automatically.
apply_changes
my $count = $app->apply_changes($changes);
Applies the collected changes to disk. Returns the number of changes applied.
log
$self->log($message);
Prints a log message to STDERR if debug is enabled.
run
App::codefork->run(@ARGV);
CLI entry point. Parses arguments and executes the appropriate command.
UPGRADE NOTICE
Version 1.000 has a completely new command-line interface.
The old --config, --dir, and --debug flags from MooX::Options are no longer supported. The new interface uses positional commands instead:
# Old (no longer works):
codefork --config fork.conf --dir /path/to/code
# New:
cd /path/to/code
codefork fork.conf
See codefork for the full new command-line syntax.
Debug output is now enabled via the CODEFORK_DEBUG=1 environment variable instead of --debug.
CONFIG FILE FORMAT
The config file (default: fork.conf) contains replacement instructions, one per line:
from|to- Replace regex patternfromwithtoin filenames and file contentsfrom%to- Replace whole wordfromwithto(non-alphanumeric boundaries enforced, sohhwon't match insideohhh)
Example config:
HomeHive|AqHive
homehive|aqhive
hh%ah
Empty lines and lines without a | or % separator are ignored.
ENVIRONMENT
CODEFORK_DEBUG-
Set to a true value to enable verbose debug output to STDERR.
SUPPORT
Issues
Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-app-codefork/issues.
CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
AUTHOR
Torsten Raudssus <torsten@raudssus.de>
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Torsten Raudssus.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.