Linux Apps Tools

Cookie – A Template-Based File Generator for Projects

Cookie - Template Based-File Generator for Projects
Written by Martins D. Okoi

Cookie is a free and open source template-based file generator that speeds up the process of writing scripts, Makefiles, LaTeX documents, and other one-off files.

Cookie demo

Cookie

Cookie is similar to cookiecutter, a command-line utility that creates projects from project templates (stylistically referred to as “cookiecutters“) in any markup format or programming language. But unlike cookiecutter, Cookie creates pages from file templates.

The templates are stored in the ~/.cookiecutters directory or the directory specified by $COOKIE_DIR. You can see examples of the main developer’s templates here.

Features in Cookie

  • Free and open source with source code available on GitHub.
  • Cross-platform: available on Windows, GNU/Linux, and macOS.
  • Quickly create files from page templates.
  • Supports aliases and functions which serve as task and filetype-specific custom initialization commands.
  • Variable substitution.

Installation of Cookie in Linux

Root Installation

With root permission all you need to do is clone the project from git and building the app with the following commands:

$ git clone https://github.com/bbugyi200/cookie
$ cd cookie
$ sudo make install
User Installation

Without root permission you will need to use an alternate bin directory which you would clone the git repo into and then build with the command:

# make DESTDIR=/home/<user>/.local PREFIX= install

Replace <user> with your username and make sure that the /home/<user>/.local/bindirectory is in your system’s path.

  Hiri - A Desktop Email Client for Microsoft Office365 and Hotmail

Usage

Usage: cookie [-d] [-D TARGET_DIR] [-f] [-m MODE] [-v] [-x] TEMPLATE [TARGET]
       cookie -c
       cookie -e TEMPLATE
       cookie -h
       cookie -l [TEMPLATE]
       cookie -r TEMPLATE

Initializes a new file (TARGET) using a predefined template (TEMPLATE).
The target file can be a new script, configuration file, markup file, etc....
After the target file has been initialized, it is opened for editing using the
system's default editor.

Positional Arguments:
    TARGET          The name of the file to initialize.

Optional Arguments:
    -d | --debug
        Enable debug mode.

    -c | --config
        Edit the configuration file.

    -D DIR | --bin-subdir DIR
        Initialize TARGET into DIR, which should be a subdirectory of the
        default bin directory (see the configuration file).

    -e TEMPLATE | --edit TEMPLATE
        Add / edit cookie template.

    -f | --force
        Force TARGET initialization to be relative to the current
        directory. This option essentially overrides the ROOT_DIR
        configuration setting. Enabled by default for non-executable
        targets.

    -h | --help
        View this help message.

    -l [TEMPLATE] | --list [TEMPLATE]
        If TEMPLATE is provided, output template contents to STDOUT.
        Otherwise, list available templates. 

    -m MODE | --mode MODE
        Sets file mode bits. Accepts any form for MODE that is recognized
        by the 'chmod' command.

    -r TEMPLATE | --remove TEMPLATE
        Delete cookie template.

    -x
        Make TARGET executable. Equivalent to '-m +x'.

    -v | --verbose
        Enable verbose output.

Using Cookie should come easily to you if you are familiar with Cookiecutter. But if you’re new to either of both tools then you need to go over the guide before delving in.

Your Unwavering Support Matters a Lot:

The cost of maintenance is skyrocketing as more readers are coming on board and the ad service that we employ in order to generate revenue is unfortunately no longer sufficient and this is especially due to the increased use of ad-blockers.

We humbly request that you consider disabling your ad-blockers to support us financially or by donating as anything from $1. Your donation(s) will go a long way in supporting FossMint and sister site, TecMint, in running efficiently. Thank you.

Make a Contribution via PayPal


Top Deals

About the author

Martins D. Okoi

Martins Divine Okoi is a graduate of Computer Science with a passion for Linux and the Open Source community. He works as a Graphic Designer, Web Developer, and programmer.