Addinclude is a small utility to add an include to a C header- or sourcefile, written in Go
Addinclude provides a simple way to add includes to C header- or sourcefiles.
Sometimes, a patch is overkill and search and replace does not cut it.
Addinclude adds the includes after the first #ifdef and preferably together with the other #include lines.
If the header is empty, or there are no #ifdefs or #includes, the include is inserted at the top of the file.
- by itself, returns errorcode 1 at exit
- addinclude myfile.h '#include <string.h>'
- adds #include <string.h> to myfile.h
- addinclude myfile.h stdlib
- adds #include <stdlib.h> to myfile.h
- addinclude myfile.c '"some.h"'
- adds #include "some.h" to myfile.c
It aims to solve a tiny problem properly instead of a
thousand problems halfway, in true UNIX-spirit.
It creates a line that is very easy to read, as opposed to
using sed for the same task.
It should be very clear from the syntax what is being done.
It's only one small executable, not a big package.
Which parameters are supported?
--version or -v for the current version
--help or -h for quick help
--nofix or -n to don't touch the include statement given on the commandline
--top or -t to put the include at the top
Addinclude ordinarily only takes a filename and an include
Alexander Rødseth 2013