1
0
Fork
You've already forked bft
0
No description
  • Zig 88%
  • Nix 12%
2025年05月28日 14:33:52 +02:00
examples update readme and a examples 2025年01月26日 20:13:46 +01:00
lib update mustage to main to be compliante with zig-0.14 2025年01月27日 21:37:55 +01:00
src update version to v0.1.1 2025年05月28日 14:33:52 +02:00
.gitignore first commit 2025年01月14日 08:30:58 +01:00
build.zig remove run artefact of build.zig 2025年03月12日 12:05:18 +01:00
build.zig.zon update version to v0.1.1 2025年05月28日 14:33:52 +02:00
default.nix update version to v0.1.1 2025年05月28日 14:33:52 +02:00
deps.nix add nix buid file 2025年05月25日 21:03:27 +02:00
LICENSE add gpl v3 or higher license 2025年01月20日 21:19:57 +01:00
readme.md update readme 2025年03月14日 17:35:09 +01:00
test.md add integration test and add it to build.zig 2025年03月12日 12:01:46 +01:00

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 var USER
  • date = date a format DD/MM/YYYY
  • file = file name use in parameter
  • fileNameAndDate = 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_date that match TOTO_DDMMYYYY (still uppercase to manage)
  • print result
  • this is work fine with helix ?
  • add git_repository_discover to get actual git dir