/NimFormattedFile

A supercharged pre-formatted file creation utility.

Primary LanguageShellMIT LicenseMIT


Logo

NimFormattedFile

Instantly create pre-formatted files.
Wiki »

Language Stars Issues License

Getting Started · Report Bug · Request Feature

Table of Contents

About

Current version: 0.0.3.

Description

A brand-new version of NewFormattedFile, re-written in Nim.

nff creates a new file with the format specified by its matching config file. For example, a file ending in .py will be created with the contents of nff’s py.tmpl. The *.tmpl files are simply plain text. You can create any *.tmpl files for any file types you like, as long as the config file’s name matches the file extension of the target file type (hpp.tmpl for *.hpp files, etc.)

Why Nim?

Nim has become a very powerful, clean, and efficient language. It combines run-time speed with ease of development; I was able to write, from scratch, NimFormattedFile in one day, while NewFormattedFile took 3-4 days. Nim deserves to be used more widely– and in an effort to further this cause, I have re-written NewFormattedFile in Nim, with an exciting roadmap of new features to come.

Supported File Types

nff has templates added frequently. Raise an Issue if you would like support added for one or more file types.

  • C
  • C++
  • JavaScript
  • Python3
  • Ruby
  • Sh(ell)

Getting Started

NimFormattedFile works as a drop-in replacement to the old NewFormattedFile.

Prerequisites

  • Nim
  • clapfn A command line argument parser library.

The easiest way to install Nim is to use choosenim. This will also install nimble, which can be used to install clapfn (see clapfn’s Installation instructions).

Installation

  1. Clone this repo.
git clone https://github.com/oliverdelancey/NimFormattedFile.git
  1. cd into the cloned directory and run install.sh.
cd nimformattedfile
chmod +x install.sh  # IMPORTANT. Give the script executable permissions.
./install.sh

Uninstallation

Run the provided uninstall script.

chmod +x uninstall.sh
./uninstall.sh

Build From Source

  1. Clone this repo.
git clone https://github.com/oliverdelancey/NimFormattedFile.git
  1. Enter the directory, and compile nff.
cd NimFormattedFile
nim c -d:release nff.nim
  1. Copy the executable to /usr/local/bin.
  2. If you have never installed any version of nff before, create the config directory in your default config directory ($XDG_CONFIG_HOME or $HOME/.config) and copy the templates folder there.
mkdir ~/.config/nff
cp templates ~/.config/nff

Otherwise, if you have previously installed nff, the C++ or Nim version, copy any .tmpl files you may not have to your templates folder.

Usage

Just run nff my_file.ext. For example:

nff awesome_program.cpp
cat awesome_program.cpp
#include <iostream>

int main(int argc, char** argv) {
    std::cout << "C++ file generated by nff" << std::endl;
}

Run nff --help for complete help.

NimFormattedFile v0.0.3
Create a new file designated by the input file's extension.

Usage: nff [-h] [-v]  file

Required arguments:
    file           The file to create.

Optional arguments:
    -h, --help     Show this help message and exit.
    -v, --version  Show version number and exit.

Roadmap

See the wiki for the roadmap.

License

This project uses the MIT License.

Contact

Raise an Issue! I’ll see you there.

Project link: https://github.com/oliverdelancey/NimFormattedFile