Spacelocust / dahl

A usefull CLI to generate files quickly and easily from template

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dahl Logo

A Simple CLI made with Cobra package for generating files.

GitHub go.mod Go version Go Report Card GitHub Workflow Status Package License GitHub repo size GitHub Tag GitHub Releases

Sponsors

Maintainence of this project is made possible by all the contributors and sponsors. If you'd like to sponsor this project and have your avatar or company logo appear below click here. ๐Ÿ’™

Overview

Hello fellow developer!

Welcome to the Dahl repository! Dahl is a command line tool that helps developers create and use custom templates to generate files quickly and easily. With Dahl, you can save time and effort by using pre-defined templates to generate the files you need for your project, rather than starting from scratch every time.

This repository contains the source code for Dahl, as well as documentation and examples to help you get started. You can also share your own templates with the community by contributing to the repository.

Whether you're a seasoned developer or just starting out, Dahl is a valuable tool to have in your arsenal. Give it a try and see how it can streamline your workflow and save you time.

Thank you for checking out Dahl. We hope it becomes a valuable addition to your toolkit.

Getting Started

Installation

Binary Release (Linux/OSX/Windows)

You can manually download a binary release from the release page.

Automated install/update, don't forget to always verify what you're piping into bash:

curl https://raw.githubusercontent.com/Spacelocust/dahl/main/scripts/install.sh | bash

The script installs downloaded binary to $HOME/.local/bin directory by default, but it can be changed by setting DIR environment variable.

I already made an alias for zsh if you want:

echo "alias dahl='~/.local/bin/dahl'" >> ~/.zshrc

(you can substitute .zshrc for whatever rc file you're using)

Go

Required Go Version >= 1.16

go install github.com/Spacelocust/dahl@latest

Required Go version >= 1.8, <= 1.17

go get github.com/Spacelocust/dahl

Docker

Docker Pulls Docker Stars Docker Automated Docker Image Version (latest semver)

docker run --rm -it -v /your/project/path:/app -w /app spacelocust/dahl:latest

Usage

In your root project, use the following commande for generating a dahl-config.yml and .dahl directory

dahl init

Use hello-world flag if you want a example template and configuration

dahl init --hello-world

The dahl-config.yml will grouping all of your template configuration

## dahl-config.yml
templates:

  ## list template
  [template name]:
    to: # destination path of generating file
    from: # location path of template file
    filename: # filename of generating file
    prefix: # prefix filename
    suffix: # suffix filename
    
    ## list props (custom keys)
    props:
      [prop name]:

Commands

## base command
dahl [command] [template] [flags]

You can use flags to overwrite some value from the config file, like filename, destination...

Flags:
    -n, --filename   (string)
    --from           (string)  
    --to             (string)
    --props          (json)
    -p, --prefix     (string)
    -s, --suffix     (string)
    -e, --extension  (string)
    -f, --force
    -y, --yes

"Filename, From, To" value are required, you must specify them with the cli or config file.

Info: the config file isn't required, you can use templating with the cli this way:

dahl run 
  --from /my/template/path 
  --to /my/destination/path
  --filename my-file

Template

pattern description
_{ value }_ related to file keys
_{ @value }_ custom props keys

Examples

dahl run express-controller -n User
## dahl-config.yml
templates:

  express-controller:
    to: "./src/controller"
    from: "/express/controller/my-controller.dahl"
    extension: ".js"
    props:
      http:
        status: 
          ok: 200
// my-controller.dahl

export const get_{ filename }_ = (req, res) => {
  // stuff
  return res.status(_{ @http.status.ok }_).send()
}

export const update_{ filename }_ = (req, res) => {
  // stuff
  return res.status(_{ @http.status.ok }_).send()
}

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

There is still a lot of work to go! Please check out the contributing guide. For contributor discussion about things not better discussed here in the repo, join the discord channel

Support

Reach out to the maintainer at one of the following places:

License

This project is licensed under the MIT license.

See LICENSE for more information.

Acknowledgements

About

A usefull CLI to generate files quickly and easily from template

License:MIT License


Languages

Language:Go 93.2%Language:Shell 4.7%Language:Makefile 1.9%Language:Dockerfile 0.2%