A Simple CLI made with Cobra package for generating files.
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. π
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.
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)
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 run --rm -it -v /your/project/path:/app -w /app spacelocust/dahl:latest
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]:
## 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
pattern | description |
---|---|
_{ value }_ | related to file keys |
_{ @value }_ | custom props keys |
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()
}
See the open issues for a list of proposed features (and known issues).
- Top Feature Requests (Add your votes using the π reaction)
- Top Bugs (Add your votes using the π reaction)
- Newest Bugs
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
Reach out to the maintainer at one of the following places:
- GitHub discussions
- The email which is located in GitHub profile
This project is licensed under the MIT license.
See LICENSE for more information.
- lazydocker - File structuration
- docker - Command-line architecture