file-templates: Use templates for files and directories

[ bsd3, cli, program, template ] [ Propose Tags ] [ Report a vulnerability ]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 1.0.0.0, 1.1.0.0
Dependencies attoparsec (>=0.13.1.0 && <0.14), base (>=4.7 && <5), bytestring (>=0.10.8.1 && <0.11), directory (>=1.3.0.0 && <1.4), filepath (>=1.4.1.1 && <1.5), foundation (>=0.0.9 && <0.1), transformers (>=0.5.2.0 && <0.6), unordered-containers (>=0.2.8.0 && <0.3) [details]
License BSD-3-Clause
Copyright BSD3
Author Anton Felix Lorenzen
Maintainer anfelor@posteo.de
Category CLI, Template
Home page https://github.com/anfelor/file-templates#readme
Uploaded by anfelor at 2017-07-01T19:03:04Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Executables new
Downloads 1764 total (2 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
Last success reported on 2017-07-01 [all 3 reports]

Readme for file-templates-1.1.0.0

[back to package description]

A simple templating system for files and directories

Assuming you have a directory ~/.templates/post:

$ tree ~/.templates/
/home/me/.templates/
└── post
    ├── author
    │   ├── file.md
    │   └── ??name2?.md
    ├── ?env?LANGUAGE?.md
    └── ??name?.md

2 directories, 4 files

Go into a new directory and execute new post:

$ new post
Please give a value for 'name': Hello 
Please give a value for 'name2': World

$ tree
.
├── author
│   ├── file.md
│   └── World.md
├── en_US.md
└── Hello.md

1 directory, 4 files

Voilà!

How it works

It accepts one argument dir and then looks up either ~/.templates/dir/, or %APPDATA%/dir/. It then substitutes

  • ??xxx? by asking the user: Please give a value for 'xxx':
  • ?env?xxx? by reading the environment variable xxx

in both filenames and file contents, then copying the files into the current directory (if that introduces slashes in a file name, it will happily split the filename into directory structure). This tool works best with other simple tools like sos and shake in my experience.

Possible issues

  1. It should work on Windows, but that has not been tested.
  2. There are no unit tests.

Contributing

Contributions are always welcome, as long as they:

  • Keep it simple
  • Work cross-platform

Possible candidates include:

  • Testing
  • Adding new variable resources (git config, etc.)