hinit: Generic project initialization tool

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

hinit is a generic project initialization tool similar to cookiecutter.


[Skip to Readme]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0, 0.2.0, 0.2.1, 0.2.2
Change log CHANGELOG.md
Dependencies base (>=4.10 && <5), Cabal (>=3.2.0 && <3.5), containers (>=0.6.2 && <0.7), directory (>=1.3.6 && <1.4), exceptions (>=0.10.4 && <0.11), fused-effects (>=1.1.0 && <1.2), Glob (>=0.10.1 && <0.11), haskeline (>=0.8.1 && <0.9), hinit, megaparsec (>=9.0.0 && <9.3), mustache (>=2.3.1 && <2.4), optics-core (>=0.3.0 && <0.5), optparse-applicative (>=0.15.1 && <1.17), parser-combinators (>=1.2.1 && <1.3), path (>=0.7.0 && <0.10), path-io (>=1.6.2 && <1.7), prettyprinter (>=1.6.2 && <1.8), prettyprinter-ansi-terminal (>=1.1.2 && <1.2), process (>=1.6.9 && <1.7), spdx-license (>=0.1.0 && <0.2), string-interpolate (>=0.3.0 && <0.4), text (>=1.2.3 && <1.3), time (>=1.9.3 && <1.13), tomland (>=1.3.1 && <1.4) [details]
Tested with ghc >=8.10 && <=9.0.2
License BSD-3-Clause
Copyright Copyright (c) Poscat 2020
Author Poscat
Maintainer Poscat <poscat@mail.poscat.moe>
Revised Revision 1 made by Poscat at 2022-09-05T23:30:03Z
Category Cli
Home page https://github.com/poscat0x04/hinit
Bug tracker https://github.com/poscat0x04/hinit/issues
Source repo head: git clone https://github.com/poscat0x04/hinit
Uploaded by Poscat at 2021-10-18T03:02:51Z
Distributions NixOS:0.2.2
Executables hi
Downloads 541 total (10 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for hinit-0.2.2

[back to package description]

hinit

Hackage

hi is a generic project initialization tool that is written in Haskell. It is similar to cookiecutter in functionality.

Installation

Currently it's only possible to compile hi from source.

cabal

After cloning this repository, run:

$ cabal install hi

nix

To build hi, run:

$ nix build github:poscat0x04/hinit

After that, you could install hi to your user profile by running:

nix-env -i ./result ./result-data

If you instead want to install hi as a sysetm package, you could make this repository a input of your flake and add defaultPackage to systemPackages.

Usage

  1. Initialize a project
$ hi init haskell my-project

which creates a project with the following directory structure:

my-project
├── cabal.project
├── CHANGELOG.md
├── hie.yaml
├── LICENSE
├── my-project.cabal
├── README.md
├── src
└── test
    └── Spec.hs
  1. List all templates available
$ hi list

which outputs:

- local templates
  • haskell

Configuration

Global configuration

Global configuration is read from $XDG_CONFIG_HOME/hi/config.toml. If this file is not present on your system, hi will ask for user inputs so that a minimal configuration can be constructed.

Top-level configuration options:

  • name :: string
    required, your full name, used in LICENSE files and some default templates
  • github_username :: string
    required, your github username, used in some default templates
  • email :: string
    required, your email, used in some default templates
  • license :: string
    optional, the default license, must be a valid SPDX license identifier.
  • vcs :: string
    optional, the version control tool, can by any string but Git, Darcs, Mercurial, Pijul has special meanings (hi will call these vcs tools after the project has been initialized)

Addtionaly, default values of variables can be set under the table [custom], note that the value must be either a bool or a piece of text.

Templating

Unlike cookiecutter, hi uses mustache, a much simpler templating language for writing project templates. User templates are placed under $XDG_DATA_HOME.

Template configuration

Every template is required to have a config file template.toml and here are its configuration options:

  • desc :: string
    optional, description for the template.
  • ignores :: [string]
    required, ignored files, can use globbing syntax. Note that when judging whether a file should be ignored, it is the file's path relative the the root of the template that will be matched against the patterns specified here, not just the file name.
  • tags :: [string]
    required, tags (duh), currently this is not being used by any command.
  • options :: array of tables
    parameters of the template.
    suboptions:
    • name :: string
      required, the name of the option.
    • desc :: string
      optional, the description for this option.
    • type :: string
      rquired if default is not set, otherwise it will be ignored completely, the type of this option, currently only supports "bool" and "text".
    • default :: string | bool
      optional, the default value for this option, if this is not set then the program will ask for user input when initializing a project from this template
  • optionals :: array of tables
    optionally ignored files, when the expression specified by when evaluates to true, the ignores field will be merged into the top-level ignored files.
    suboptions:
    • when :: string
      required, an arbitrary boolean expression constructed from variables (must contain only alphanumeric characters), negations (! or ¬), conjunctions (& or ) and disjunctions (| or ), can have parenthesis.
    • ignores :: [string]
      required, see the description of the top-level ignores option.

When initializing from a template, both the the file content and the file name will be read as mustache templates. After performing a substitution, the new file will be written to the corresponding location inside the project directory.

You can also take a look at bundled templates.

Special variables names

hi will set the values for some special variables and can overwrite user configs. These names should not be used in your options. These special variables include:

  • name, email, github_usernmae, license
  • year, month, day, iso8601: system time
  • project: the name of the project that is trying to create.