Skip to content
/ cppmv Public

(Deprecated) Simple utility for moving/renaming files in a CPP source folder without breaking includes

Notifications You must be signed in to change notification settings

ludamad/cppmv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

EDIT: This is old and just a curiousity. Do not use this. Please just use a good IDE that resolves moves and/or a sane include strategy with absolute paths so you can do a consistent rename

cppmv

Simple utility for moving files in a CPP source folder without breaking includes/header guards

Usage: cppmv [--git --cmake --sort] src dst

Can support moving directories or files. Destination directories will be merged, however end file locations cannot already exist. Does not currently abitrary amount of pairs of src, dst arguments (can be done with work on the bash wrapper).

Does not at this moment support directories with spaces in them due to the bash wrapper implementation.

--git: use git mv so files remain tracked nicely

--cmake: update CMakeLists.txt if present, makes a rather naive assumption that all source files are somewhere in file, one line per file. The CMakeLists.txt file must be in the current working folder.

--sort: Sort includes alphabetically and from least-nested to most-nested. Does not attempt to group them nicely at this time, simply swapping their locations.

The tool is implemented as a bash script over a small C++-programmed utility.

Building

g++ -o cppmv-update cppmv-update.cpp

Running:

cppmv [--git --cmake --sort] src dst cppmv must be in the same directory as an executable called cppmv-update (created from cppmv-update.cpp)

Examples:

cppmv src/a.h src/b.h

Effect: rename the file and update all includes that reference a.h

cppmv src/a.cpp src/foo/a.cpp

Effect: move the file and update all includes in a.cpp to work with the new location

cppmv can move whole folders, but does not implicitly move files into folders (you cannot do src/a.h src/foo/ in the previous example).

Assumptions:

cppmv assumes includes of the form #include <myfile.h> (angle brackets) are from external libraries and will not update them. cppmv assumes includes of the form #include "myfile.h" are relative paths and will update them globally.

cppmv will read in its file in its entirety and then write back the file, and it may take a bit of time. I advise only using this tool if your source is under version control, and using the source controls diff tool to ensure that the changes are correct.

About

(Deprecated) Simple utility for moving/renaming files in a CPP source folder without breaking includes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages