|
2 | 2 | [](https://codecov.io/gh/pkrll/Hazel)
|
3 | 3 | <img src=".assets/hazel.png" data-canonical-src=".assets/hazel.png" />
|
4 | 4 |
|
5 |
| -**Hazel** is a command line tool that helps you start a new project faster -- by setting up the structure and generating common files. |
| 5 | +``Hazel`` is a **cross-platform project scaffolding tool** that makes it easier to start new projects. The CLI application **generates the directory structure and boilerplate code** for your projects, based on **predefined templates**, and can **easily** be **customized and extended**. |
6 | 6 |
|
7 |
| -- [x] Support for C projects |
8 |
| -- [ ] Support for even more languages |
9 |
| -- [ ] Generate git repository |
| 7 | +- [x] Generate project structure based on templates |
| 8 | +- [x] Support for macOS |
| 9 | +- [ ] Support for Linux |
10 | 10 |
|
11 |
| -### Installation |
| 11 | +## Table of contents |
12 | 12 |
|
13 |
| -Clone this repository, and run ``make install``: |
| 13 | +* [Usage](#usage) |
| 14 | + * [Customization](#customization) |
| 15 | + * [Example](#example) |
| 16 | + * [Placeholders](#placeholders) |
| 17 | + * [Command-line options](#command-line-options) |
| 18 | +* [Installation](#installation) |
| 19 | + * [Prerequisites](#prerequisites) |
| 20 | +* [Acknowledgements](#acknowledgements) |
| 21 | + |
| 22 | +## Usage |
| 23 | + |
| 24 | +Run ``Hazel`` inside the root folder for your project with the ``init`` command, along with the ``--type``, or ``-t``, flag to generate the directory structure and the files: |
14 | 25 |
|
15 | 26 | ```bash
|
16 |
| -$ git clone https://github.com/pkrll/Hazel |
17 |
| -$ cd Hazel |
18 |
| -$ make install |
| 27 | +$ mkdir SomeApp && cd SomeApp |
| 28 | +$ hazel init --type c |
| 29 | + |
| 30 | +Created obj |
| 31 | +Created bin |
| 32 | +Created tests |
| 33 | +Created src |
| 34 | +Created obj/.gitkeep |
| 35 | +Created bin/.gitkeep |
| 36 | +Created Makefile |
| 37 | +Created tests/SomeApp_test.c |
| 38 | +Created src/SomeApp.c |
| 39 | +Created .editorconfig |
19 | 40 | ```
|
20 | 41 |
|
21 |
| -This will install **Hazel** in ``/usr/local/bin``, along with its templates files in ``~/.hazel``. |
| 42 | +<img src=".assets/hazel.gif"> |
| 43 | + |
| 44 | +### Customization |
| 45 | + |
| 46 | +``Hazel`` generates new projects based on predefined templates, placed in ``~/.hazel/templates``. You can add your own templates by simply creating a desired directory structure, along with the files you want to be automatically generated, in a subdirectory to ``~/.hazel/templates``. |
22 | 47 |
|
23 |
| -### Usage |
| 48 | +The name of the subdirectory will serve as the name of the project. |
24 | 49 |
|
25 |
| -Run **Hazel** inside the root folder for your project to generate the directory structure: |
| 50 | +#### Example |
| 51 | + |
| 52 | +Let's create a (**very**) simple template for Swift projects. |
26 | 53 |
|
27 | 54 | ```bash
|
28 |
| -$ mkdir SomeProject |
29 |
| -$ hazel --type c |
| 55 | +$ cd ~/.hazel/templates |
30 | 56 |
|
31 |
| -Created bin |
32 |
| -Created obj |
| 57 | +$ mkdir Swift && cd Swift |
| 58 | +$ touch README.md |
| 59 | +$ mkdir src |
| 60 | +$ touch src/__PROJECTNAME__.swift |
| 61 | + |
| 62 | +# __PROJECTNAME__ is a placeholder that will be |
| 63 | +# replaced by the project name when running hazel |
| 64 | + |
| 65 | +$ tree |
| 66 | +. |
| 67 | +├── README.md |
| 68 | +├── src |
| 69 | + └── __PROJECTNAME__.swift |
| 70 | +``` |
| 71 | + |
| 72 | +To generate new projects based on the above template, we can now initiate a new project of type ``swift``: |
| 73 | + |
| 74 | +```bash |
| 75 | +$ mkdir AwesomeApp && cd AwesomeApp |
| 76 | +$ hazel init --type swift |
| 77 | + |
| 78 | +Created README.md |
33 | 79 | Created src
|
34 |
| -Created tests |
35 |
| -Created Makefile |
| 80 | +Created src/AwesomeApp.c |
36 | 81 | Created .editorconfig
|
37 | 82 | ```
|
38 | 83 |
|
39 |
| -##### Command line options |
| 84 | +#### Placeholders |
| 85 | + |
| 86 | +When generating new projects, ``Hazel`` will replace all occurrences of placeholder variables in the template with appropriate values. This includes both file and directory names as well as the actual contents of the template files. |
| 87 | + |
| 88 | +As of now, support exists for the following placeholders: |
| 89 | + |
| 90 | +| Placeholder | Description | |
| 91 | +| :------------- | :------------- | |
| 92 | +| ``__PROJECTNAME__`` | All occurrences of this placeholder will be replaced with the name of the project. | |
| 93 | +| More to come | ... | |
| 94 | + |
| 95 | +#### Commandline options |
40 | 96 |
|
41 | 97 | ```bash
|
42 |
| -Usage: hazel [options] |
43 |
| - -t, --type: |
44 |
| - Choose language for project: [c|c++|swift|java|erlang] |
45 |
| - --no-makefile: |
46 |
| - Do not generate Makefile |
47 |
| - --no-config: |
48 |
| - Do not generate .editorconfig |
49 |
| - -h, --help: |
50 |
| - Print help message and exit |
51 |
| - -v, --version: |
52 |
| - Print version information and exit |
| 98 | +Usage: hazel [command] [argument] |
| 99 | + |
| 100 | +Commands: |
| 101 | + init Initiate a new project |
| 102 | + |
| 103 | +Options: |
| 104 | + -h, --help Print help message and exit |
| 105 | + -v, --version Print version information and exit |
| 106 | + |
53 | 107 | ```
|
54 | 108 |
|
55 |
| -# Author |
| 109 | +## Installation |
| 110 | + |
| 111 | +``Hazel`` has only been tested on macOS High Sierra (10.13), so far, and is only available for download through Github. |
| 112 | + |
| 113 | +**Prerequisites**: |
| 114 | + |
| 115 | +* Swift 4.0 |
| 116 | +* Git |
| 117 | + |
| 118 | +Clone this repository, and run ``make install``: |
| 119 | + |
| 120 | +```bash |
| 121 | +$ git clone https://github.com/pkrll/Hazel |
| 122 | +$ cd Hazel |
| 123 | +$ make install |
| 124 | +``` |
| 125 | + |
| 126 | +This will install ``Hazel`` in ``/usr/local/bin``, along with its templates files in ``~/.hazel``. |
| 127 | + |
| 128 | +## Acknowledgements |
56 | 129 |
|
57 |
| -**Hazel** was created by Ardalan Samimi. The hazel nut icon was designed by [Flaticon](https://www.flaticon.com). |
| 130 | +``Hazel`` was created by [Ardalan Samimi](https://github.com/pkrll). This project is licensed under the terms of the MIT license. The hazel nut icon was designed by [Flaticon](https://www.flaticon.com). |
0 commit comments