Hatch new projects like a chick coming out of its egg

Overview

🐣 Cargo Hatch

Hatch new projects like a chick coming out of its egg.

Cargo hatch is a cargo init/cargo new on steroids, allowing complex templates thanks to the Tera engine. Additional template values can be configured and requested from the user during execution.

Why not cargo-generate instead?

This project was born out of frustration with cargo-generate. Although a great project it didn't work for me personally as I got SEGFAULTs and Git errors whenever I tried to generate a new project with it.

The main differences are:

  • Less emojis. Cargo hatch tries to keep the output simple and use colors here and there. Eventually you may discover an emoji here and there as well.
  • Local templates. Cargo hatch provides a local subcommand that simply takes any directory and treats it as template making it easy to test templates or have local private templates, Git or not.
  • More argument types. Cargo hatch tries to provide a broader selection of input types, currently including booleans, integers, floating point numbers, strings, lists (of strings) and multi-lists (of strings).
  • Tera template engine. Cargo hatch uses the Tera template engine, providing a very Jinja2-ish syntax and if you use the Zola static-site-generator, you may already be familiar with it.

Installation

To build this project have rust and cargo available in the latest version. rustup is the recommended way of installing and managing the Rust toolchain.

Then run the following command to install this project:

cargo install cargo-hatch

Make sure that your cargo binary path (usually $HOME/.cargo/bin) is available from your $PATH.

Usage

The usage of cargo-hatch is rather detailed and therefore lives in a separate file. Check out USAGE.md for further instructions.

License

This project is licensed under the AGPL-3.0 License (or https://www.gnu.org/licenses/agpl-3.0.html).

Comments
  • feat: support custom defaults in bookmarks

    feat: support custom defaults in bookmarks

    By far not the cleanest implementation, if you think this or someone like this makes sense, this would probably need to be partly refactored.

    This is more of a quickly thrown together aproach to having some form of global values.

    I first thought of global values set for all templates, but that would easily clash because multiple templates could use the same key for different use cases.

    (My usecase is e.g. the GitHub account/org).

    opened by ModProg 6
  • String validation/rust specific string types

    String validation/rust specific string types

    1. valid_ident
    2. crate-name
    3. sem.ver (I don't have any use for that one, just came to mind)
    4. a verifying pattern (regex?)

    Maybe I will look into implementing this myself

    opened by ModProg 5
  • Path filters

    Path filters

    Not sure if this is something that should be done in tera, but we could also just add these our selves.

    Specifically, I'd like a file_name filter to get the name of the path in project_name

    Also, the name project_name is a bit confusing as it actually just is the relative/absolute path, that often ends up just being a dir name.

    opened by ModProg 4
  • conditional settings

    conditional settings

    add a condition similarly to the file ignores to arguments to allow only querying some options when an earlier prompt was answered with yes.

    [bin_install]
    type = "bool"
    description = "Enable binary installer (requires releases on GitHub)"
    default = true
    
    [github_repo]
    type = "string"
    description = "Enable binary installer (requires releases on GitHub)"
    condition = "{{ bin_install }}"
    

    should only ask for github_repo if bin_install is answered with yes.

    opened by ModProg 3
  • some improvements

    some improvements

    Some improvements I thought of, feel free to filter/change

    • fix: only check is empty on existing dirs
    • fix: allow omitting ignore in repo settings
    • feat: allow using a single path directly as a string in ignores
    opened by ModProg 3
  • Only allow using the current path if empty or explicitly specified

    Only allow using the current path if empty or explicitly specified

    I just created the project in my parent directory by accident.

    I think there is a reason many tools only allow using an existing directory if it is empty.

    Maybe a compromise could be to either ask "Are you sure you want to hatch in this non empty directory direcotry_name?" or require passing the current directory as . .

    I hope I don't anoy you too much with these issues. It's a great tool, and I really enjoy using it.

    opened by ModProg 2
  • feat: support ignoring files from templating

    feat: support ignoring files from templating

    This supports excluding files from being executed as a template but keeps them arround to be used by templates.

    This allows both files containing invalid templates without wrapping them in {% raw %}, but more importantly it allows macros.

    The problem with macros is, that they are not allowed in templates, so this is the only way to implement them.

    files with template = false are now added to template_files so they can be referenced, but they are not rendered as templates them selves.

    closes #14 somewhat resolves #9

    opened by ModProg 5
  • "ignored" base templates

    I created a base template containing some boilerplate for my github workflow files.

    I'd like to use it for generating, but exclude it from the output. https://tera.netlify.app/docs/#base-template

    I cannot add it to .hatchignore because then it will not be present for the template generation.

    opened by ModProg 0
  • Dynamic Validation

    Dynamic Validation

    My Idea would be to have it run with the context of already specified arguments (Hopefully we find a good way to do this in #8).

    • if it evaluates to only whitespace the value is valid
    • else the result is printed as error message
    opened by ModProg 1
  • Updating a template

    Updating a template

    We discussed this earlier, but I have a few ideas that should make this viable:

    1. from from either a tag e.g. "0.1" or from a commit sha 0c4a3.
    2. Modes for cleaning up files generated by from version a. force-clean: Delete all files that were created by from version b. try-clean: Check if any files created by from version were changed, if yes fail. c. partial-clean: Only delete all the files that were not changed
    3. Modes for generating new files a. force-gen: Replace existing files with newly generated ones b. try-gen: Fail if any files would be overwritten c. partial-gen: Only generate files that would not overwrite existing ones.
    4. Have combined modes, i.e. force, try, partial
    5. For values: a. have some form of input file b. just respecify all the values, as they might have changed from version to version as well.

    With a vc project you can just use force and than have a look at the diff.

    opened by ModProg 1
  • Dynamic values

    Dynamic values

    Same behavior as with defaults (using json for encoding of list and multi_list).

    My usecase:

    First question selects a set of features.

    Second question selects one of them as default: should only offer the ones selected in question 1.

    opened by ModProg 1
  • custom delimiters for tera

    custom delimiters for tera

    I have a file using terra like templates inside a template.

    So having the ability to change the delimter to some other character would be great.

    Related tera issue: https://github.com/Keats/tera/issues/343

    opened by ModProg 8
Owner
Dominik Nakamura
Rust, Go and Kotlin enthusiast
Dominik Nakamura
Template for Cargo based SysY compiler projects.

基于 Cargo 的 SysY 编译器项目模板 该仓库中存放了一个基于 Cargo 的 SysY 编译器项目的模板, 你可以在该模板的基础上进行进一步的开发. 该仓库中的 Rust 代码实现仅作为演示, 不代表你的编译器必须以此方式实现. 如你需要使用该模板, 建议你删掉所有 Rust 源文件, 仅

PKU Compiler Course 1 Nov 1, 2021
Templates for creating rust projects with a GitHub-managed lifecycle with cargo-generate 🏗️📃

rust-templates Templates for creating rust projects with a GitHub-managed lifecycle with cargo-generate. ??️ ?? What you get: PR build validation usin

Ben Greenier 1 Oct 30, 2021
Type-safe, compiled Jinja-like templates for Rust

Askama Askama implements a template rendering engine based on Jinja. It generates Rust code from your templates at compile time based on a user-define

Dirkjan Ochtman 2k Jan 5, 2023
Compiler for Jade-like template language to cito.js-based virtual dom

Marafet A very experimental DSL for creating (mostly) single page applications in HTML. It's mostly a Jade-like (or Haml-like) templating language wit

Paul Colomiets 11 Jun 25, 2020
A prolog like syntax for egg

egglog Using the egg library with a file format and semantics similar to datalog. Explanatory blog posts: https://www.philipzucker.com/egglog-checkpoi

Philip Zucker 40 Dec 1, 2022
CLI utility to move (or rename) your files to a new location and redirect all of its symbolic links, to the new path

Move Links CLI utility to move (or rename) your files to a new location and redirect all of its symbolic links, to the new path (or name). Usage execu

Ben Mefteh 18 May 22, 2022
Python bindings for egg

Python bindings for egg Installing Install maturin, a cool Rust/Python builder thingy. Download from their site or just pip install maturin. Type make

null 28 Dec 25, 2022
figure out who holds the nfts that came out of a candy machine.

Candy Holders This is far from finished, but can: find tokens with a given update authority find holders of those tokens Neither the Rust or Node APIs

ExiledApes 24 Dec 29, 2022
Druid Exporter plays a fundamental role as a receiver of metrics events coming from Druid clusters, adopting the HTTP format as a means of communication

Druid Exporter plays a fundamental role as a receiver of metrics events coming from Druid clusters, adopting the HTTP format as a means of communication. In addition to this capability, its primary function is to export these metrics to Prometheus, thus allowing the creation of meaningful graphs and visualizations.

Kiwfy 3 Sep 21, 2023
Winter is coming...

WinterJS The JavaScript server that runs Service Workers according to the Winter Community Group specification. Running WinterJS with Wasmer The Winte

Wasmer 7 Oct 6, 2023
Druid Exporter plays a fundamental role as a receiver of metrics events coming from Druid clusters, adopting the HTTP format as a means of communication.

Druid Exporter plays a fundamental role as a receiver of metrics events coming from Druid clusters, adopting the HTTP format as a means of communication. In addition to this capability, its primary function is to export these metrics to Prometheus, thus allowing the creation of meaningful graphs and visualizations.

Not Empty Free Software Foundation 5 Oct 24, 2023
Rushes are new ephemeral projects at Hive Helsinki. Wordle is the first in this series with 48 hours time window

Rushes are new ephemeral projects at Hive Helsinki. Wordle is the first in this series with 48 hours time window

Jiri Novotny 1 Feb 24, 2022
A simple cli to clone projects and fetch all projects in a GitHub org..

stupid-git A simple cli to clone projects and update all projects. get all repository from GitHub clone all pull all with git stash Usage create sgit.

Fengda Huang 5 Sep 15, 2022
Shell Of A New Machine: Quickly configure new environments

Shell Of A New Machine soanm is a dead-simple tool for easily configuring new UNIX machines, with almost zero prerequisites on the target machine. All

Ben Weinstein-Raun 41 Dec 22, 2022
Dash is a CLI tool that rapidly sets up new projects by running a series of pre-defined commands.

Dash Dash is a CLI tool that rapidly sets up new projects by running a series of pre-defined commands. Features Quick Initialization: Initialize the c

Kunal Bagaria 4 Nov 7, 2023
It's implemented by laying out the elements in memory contiguously like alloc::vec::Vec

A Vec<T: ?Sized> It's implemented by laying out the elements in memory contiguously like alloc::vec::Vec Layout A Vechonk is 4 usize long. It owns a s

nils 4 Sep 15, 2022
Rust Server Components. JSX-like syntax and async out of the box.

RSCx - Rust Server Components RSCx is a server-side HTML rendering engine library with a neat developer experience and great performance. Features: al

Antonio Pitasi 21 Sep 19, 2023
Command-line client for WebSockets, like netcat (or curl) for ws:// with advanced socat-like functions

websocat Netcat, curl and socat for WebSockets. Examples Connect to public echo server $ websocat ws://echo.websocket.org 123 123 ABC ABC Serve and c

Vitaly Shukela 5k Jan 4, 2023
A tool that, like, screams at you when you say like

Dislike Do you, like,... dislike constantly saying "like" as much as I do? Then, like,... you've come the right place! This tool is like EXACTLY what

ElKowar 27 Jun 27, 2022
A bit like tee, a bit like script, but all with a fake tty. Lets you remote control and watch a process

teetty teetty is a wrapper binary to execute a command in a pty while providing remote control facilities. This allows logging the stdout of a process

Armin Ronacher 259 Jan 3, 2023