- Zig 88%
- Nix 12%
| examples | update readme and a examples | |
| lib | update mustage to main to be compliante with zig-0.14 | |
| src | update version to v0.1.1 | |
| .gitignore | first commit | |
| build.zig | remove run artefact of build.zig | |
| build.zig.zon | update version to v0.1.1 | |
| default.nix | update version to v0.1.1 | |
| deps.nix | add nix buid file | |
| LICENSE | add gpl v3 or higher license | |
| readme.md | update readme | |
| test.md | add integration test and add it to build.zig | |
bft
Small program to create new file from template. Template is based on mustache syntax.
This program come from my switch from vim to helix. The template system of vim (via buffNewFile) realy missed me in helix. So this try to fill the gap.
HowTo use
when you call bft my_file.c, the program look at ~/.config/bft/ to find c.tpl file.
Write a template
Template must be located at: ~/.config/bft/yourTemplate.tpl and
the template name must match your file type, for example for toto.c
the right template name is c.tpl.
For now it manage this keyword:
author= try to get author name from git config if it failed, get it from env varUSERdate= date a format DD/MM/YYYYfile= file name use in parameterfileNameAndDate= concat of file name (without ext) and date. I use it for header guard of c header files
You can find template examples of tpl in this folder.
Using it with helix
While you're in helix and want to create a new file, start by creating
a new buffer (example: :o toto.c). Now while you're in this new buffer
type for example !bft toto.c to insert a prefilled template of a c file.
HowTo compile
To compile this project you must have a zig v0.14 toolchain.
You can found it on this page.
After that, simply run zig build at the project root folder.
git clone https://codeberg.org/tanche/bft.git
cd bft
# to get mustache dependency
git submodule update
zig build
And to run tests, first you must install bbt and after you can run
zig build test
dependencies
Todo
- add test
- internal test ?
- bb test with bbt
- check bbt is available in build.zig
- add cli to specify template directory
- parse arg
- read args
- check args
- add a version output (for fun and learn)
- get file name from helix
- get tpl from arg
- with file type as parameter
- with file to create (ex: toto.c) as parameter
- add possibility to get template from nam and not from type (ex: build.zig)
- read file
- get ~/.config path
- find rigth .tpl file
- read it
- fill tpl
- fill template mustache value from data
- get date from system
- replace zig datetime by c stdlib time.h (the zig datetime lib seem to not be maintain)
- get user from git or system
- add field
file_and_datethat matchTOTO_DDMMYYYY(still uppercase to manage)
- print result
- this is work fine with helix ?
- add
git_repository_discoverto get actual git dir