{"id":13903013,"url":"https://github.com/kozmod/progen","last_synced_at":"2025-04-13T17:23:09.975Z","repository":{"id":65149643,"uuid":"583922355","full_name":"kozmod/progen","owner":"kozmod","description":"A flexible, language and frameworks agnostic tool that allows you to generate projects structure from templates based on yaml configuration.","archived":false,"fork":false,"pushed_at":"2024-12-11T07:18:16.000Z","size":369,"stargazers_count":7,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T08:11:38.934Z","etag":null,"topics":["cli","cli-tool","generation","generator","go","golang","progen","project-generator","toolkit"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kozmod.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-31T13:26:43.000Z","updated_at":"2024-12-11T07:18:20.000Z","dependencies_parsed_at":"2024-01-28T12:28:30.771Z","dependency_job_id":"5cb62f8e-5019-4f6c-a370-94c9e0262048","html_url":"https://github.com/kozmod/progen","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kozmod%2Fprogen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kozmod%2Fprogen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kozmod%2Fprogen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kozmod%2Fprogen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kozmod","download_url":"https://codeload.github.com/kozmod/progen/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248750938,"owners_count":21155801,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","cli-tool","generation","generator","go","golang","progen","project-generator","toolkit"],"created_at":"2024-08-06T22:01:33.644Z","updated_at":"2025-04-13T17:23:09.932Z","avatar_url":"https://github.com/kozmod.png","language":"Go","funding_links":[],"categories":["cli"],"sub_categories":[],"readme":"# ProGen \u003cimg align=\"right\" src=\".github/assets/PG1-4-3-1.png\" alt=\"drawing\"  width=\"60\" /\u003e\n\n[![test](https://github.com/kozmod/progen/actions/workflows/test.yml/badge.svg)](https://github.com/kozmod/progen/actions/workflows/test.yml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/kozmod/progen)](https://goreportcard.com/report/github.com/kozmod/progen)\n![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/kozmod/progen)\n![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/kozmod/progen)\n![GitHub release date](https://img.shields.io/github/release-date/kozmod/progen)\n![GitHub last commit](https://img.shields.io/github/last-commit/kozmod/progen)\n[![GitHub MIT license](https://img.shields.io/github/license/kozmod/progen)](https://github.com/kozmod/progen/blob/main/LICENSE)\n\nA flexible, language and frameworks agnostic tool that allows you to generate projects structure from templates based\non `yaml` configuration (generate directories, files and execute commands) or use as library to build custom generator.\n___\n\n### Installation\n\n```shell\ngo install github.com/kozmod/progen@latest\n```\n\n### Build from source\n\n```shell\nmake build\n```\n### Use as `lib` [\u003csup\u003e**ⓘ**\u003c/sup\u003e](#lib_usage)\n```go\nmodule github.com/some/custom_gen\n\ngo 1.22\n\nrequire github.com/kozmod/progen v0.1.8\n```\n\n___\n\n### Flags\n\n| Name                                                                  |   Type   |   Default    | Description                                                                                                                                                                            |\n|:----------------------------------------------------------------------|:--------:|:------------:|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `-f`[\u003csup\u003e**ⓘ**\u003c/sup\u003e](#config_file) \u003csup\u003e**✱**\u003c/sup\u003e                 |  string  | `progen.yml` | specify configuration file path                                                                                                                                                        |\n| `-v` \u003csup\u003e**✱**\u003c/sup\u003e                                                 |   bool   |   `false`    | verbose output                                                                                                                                                                         |\n| `-dr`[\u003csup\u003e**ⓘ**\u003c/sup\u003e](#dry_run) \u003csup\u003e**✱**\u003c/sup\u003e                    |   bool   |   `false`    | `dry run` mode \u003cbr/\u003e(to verbose output should be combine with`-v`)                                                                                                                     |\n| `-awd`[\u003csup\u003e**ⓘ**\u003c/sup\u003e](#awd)                                        |  string  |     `.`      | application working directory                                                                                                                                                          |\n| `-printconf`[\u003csup\u003e**ⓘ**\u003c/sup\u003e](#print_config)                         |   bool   |   `false`    | output processed config                                                                                                                                                                |\n| `-errtrace`[\u003csup\u003e**ⓘ**\u003c/sup\u003e](#print_err_trace) \u003csup\u003e**✱**\u003c/sup\u003e      |   bool   |   `false`    | output errors stack trace                                                                                                                                                              |\n| `-pf`[\u003csup\u003e**ⓘ**\u003c/sup\u003e](#files_preprocessing)                         |   bool   |    `true`    | `preprocessing files`: load and process all files \u003cbr/\u003e(all files `actions`[\u003csup\u003e**ⓘ**\u003c/sup\u003e](#files_actio_desk)) as [text/template](https://pkg.go.dev/text/template) before creating |\n| `-tvar`[\u003csup\u003e**ⓘ**\u003c/sup\u003e](#tvar) \u003csup\u003e**✱**\u003c/sup\u003e                     | []string |    `[ ]`     | [text/template](https://pkg.go.dev/text/template) variables \u003cbr/\u003e(override config variables tree)                                                                                      |\n| `-missingkey` \u003csup\u003e**✱**\u003c/sup\u003e                                        | []string |   `error`    | set `missingkey`[text/template.Option](https://pkg.go.dev/text/template#Template.Option) execution option                                                                              |\n| `-skip`[\u003csup\u003e**ⓘ**\u003c/sup\u003e](#skip_actions)                              | []string |    `[ ]`     | skip any `action` tag \u003cbr/\u003e(regular expression)                                                                                                                                        |\n| `-gp`[\u003csup\u003e**ⓘ**\u003c/sup\u003e](#groups_of_actions)                           | []string |    `[ ]`     | set of the action's groups to execution                                                                                                                                                |\n| `-version`                                                            |   bool   |   `false`    | print version                                                                                                                                                                          |\n| `-help` \u003csup\u003e**✱**\u003c/sup\u003e                                              |   bool   |   `false`    | show flags                                                                                                                                                                             |\n\n\u003csup\u003e**✱**\u003c/sup\u003e flags accessible in the `lib`. \n___\n\n### Actions and tags\n\n| Key                                                                             |       Type        | Optional | Description                                                                                                 |\n|:--------------------------------------------------------------------------------|:-----------------:|:---------|:------------------------------------------------------------------------------------------------------------|\n|                                                                                 |                   |          |                                                                                                             |\n| settings                                                                        |                   | ✅        | `progen` settings section                                                                                   |\n|                                                                                 |                   |          |\n| settings.http[\u003csup\u003e**ⓘ**\u003c/sup\u003e](#http_client)                                   |                   | ✅        | http client configuration                                                                                   |\n| settings.http.debug                                                             |       bool        | ✅        | http client `DEBUG` mode                                                                                    |\n| settings.http.base_url                                                          |      string       | ✅        | http client base `URL`                                                                                      |\n| settings.http.headers                                                           | map[string]string | ✅        | http client base request `Headers`                                                                          |\n| settings.http.query_params                                                      | map[string]string | ✅        | http client base request `Query Parameters`                                                                 |\n|                                                                                 |                   |          |                                                                                                             |\n| settings.groups[\u003csup\u003e**ⓘ**\u003c/sup\u003e](#groups_of_actions)                           |                   | ✅        | groups of actions                                                                                           |\n| settings.groups.name                                                            |      string       | ✅        | group's name                                                                                                |\n| settings.groups.actions                                                         |     []string      | ✅        | actions names                                                                                               |\n| settings.groups.manual                                                          |       bool        | ✅        | determines that the group starts automatically (default `false`)                                            |\n|                                                                                 |                   |          |                                                                                                             |\n| dirs`\u003cunique_suffix\u003e`[\u003csup\u003e**ⓘ**\u003c/sup\u003e](#Generate)                              |     []string      | ✅        | list of directories to create                                                                               |\n|                                                                                 |                   |          |                                                                                                             |\n| rm`\u003cunique_suffix\u003e`[\u003csup\u003e**ⓘ**\u003c/sup\u003e](#rm)                                      |     []string      | ✅        | list for remove (files, dirs, all file in a dir)                                                            |\n|                                                                                 |                   |          |                                                                                                             |\n| \u003ca name=\"files_actio_desk\"\u003e\u003ca/\u003efiles`\u003cunique_suffix\u003e`[\u003csup\u003e**ⓘ**\u003c/sup\u003e](#Files) |                   | ✅        | list file's `path` and `data`                                                                               |\n| files.path                                                                      |      string       | ❌        | save file `path`                                                                                            |\n| files.local                                                                     |      string       | `❕`      | local file path to copy                                                                                     |\n| files.data                                                                      |      string       | `❕`      | save file `data`                                                                                            |\n|                                                                                 |                   |          |                                                                                                             |\n| files.get                                                                       |                   | `❕`      | struct describe `GET` request for getting file's data                                                       |\n| files.get.url                                                                   |      string       | ❌        | request `URL`                                                                                               |\n| files.get.headers                                                               | map[string]string | ✅        | request `Headers`                                                                                           |\n| files.get.query_params                                                          | map[string]string | ✅        | request `Query Parameters`                                                                                  |\n|                                                                                 |                   |          |                                                                                                             |\n| cmd`\u003cunique_suffix\u003e`[\u003csup\u003e**ⓘ**\u003c/sup\u003e](#Commands)                               |                   | ✅        | configuration command list                                                                                  |\n| cmd.exec                                                                        |      string       | ❌        | command to execution                                                                                        |\n| cmd.args                                                                        |      []slice      | ✅        | list of command's arguments                                                                                 |\n| cmd.dir                                                                         |      string       | ✅        | execution commands (`cmd.exec`) directory                                                                   |\n|                                                                                 |                   |          |                                                                                                             |\n| fs[\u003csup\u003e**ⓘ**\u003c/sup\u003e](#fs)                                                       |     []string      | ✅        | execute [text/template.Option](https://pkg.go.dev/text/template#Template.Option) on the list of directories |\n\n`❕` only one must be specified in parent section\n\n___\n\n## Usage\n\n### Generate\n\nThe cli executes commands and generate files and directories based on configuration file\n\n```yaml\n## progen.yml\n\n# list directories to creation\ndirs:\n  - x/y\n\n# list files to creation\nfiles:\n  - path: x/some_file.txt\n    data: |\n      some data\n\n# list commands to execution \ncmd:\n  - touch second_file.txt\n  - tree\n```\n\n```console\n% progen -v\n2023-02-05 14:11:47\tINFO\tapplication working directory: /Users/user_1/GoProjects/service\n2023-02-05 14:11:47\tINFO\tconfiguration file: progen.yml\n2023-02-05 14:11:47\tINFO\tfile process: x/some_file.txt\n2023-02-05 14:11:47\tINFO\tdir created: x/y\n2023-02-05 14:11:47\tINFO\tfile saved: x/some_file.txt\n2023-02-05 14:11:47\tINFO\texecute [dir: .]: touch second_file.txt\n2023-02-05 14:11:47\tINFO\texecute [dir: .]: tree\nout:\n.\n├── second_file.txt\n└── x\n    ├── some_file.txt\n    └── y\n\n2 directories, 2 files\n```\n\n### Execution\n\nAll actions execute in declared order. Base actions (`dir`, `files`,`cmd`) could be configured\nwith `\u003cunique_suffix\u003e` to separate action execution.\n\n```yaml\n## progen.yml\n\ndirs1:\n  - api/some_project/v1\ncmd1:\n  - chmod -R 777 api\ndirs2:\n  - api/some_project_2/v1\ncmd2:\n  - chmod -R 777 api\n```\n\n```console\n% progen -v\n2023-01-22 13:38:52\tINFO\tapplication working direcotry: /Users/user_1/GoProjects/service\n2023-01-22 13:38:52\tINFO\tdir created: api/some_project/v1\n2023-01-22 13:38:52\tINFO\texecute [dir: .]: chmod -R 777 api\n2023-01-22 13:38:52\tINFO\tdir created: api/some_project_2/v1\n2023-01-22 13:38:52\tINFO\texecute [dir: .]: chmod -R 777 api\n```\n\n### Templates\n\nConfiguration preprocessing uses [text/template](https://pkg.go.dev/text/template) of golang's `stdlib`.\nUsing templates could be useful to avoiding duplication in configuration file.\nAll `text/template` variables must be declared as comments and can be used only to configure data of configuration\nfile (all ones skipping for `file.data` section).\nConfiguration's `yaml` tag tree also use as `text/template` variables dictionary and can be use for avoiding duplication\nin configuration file and files contents (`files` section).\n\n```yaml\n## progen.yml\n\n## `text/template` variables declaration 👇\n# {{$project_name := \"SOME_PROJECT\"}}\n\n## unmapped section (not `dirs`, `files`, `cmd`, `http`) can be use as template variables\nvars:\n  file_path: some/file/path\n\ndirs:\n  - api/{{$project_name}}/v1 # used from `text/template` variables\n  - internal/{{.vars.file_path}} # used from `vars` section\n  - pkg/{{printf `%s-%s` $project_name `data`}}\n\nfiles:\n  - path: internal/{{$project_name}}.txt\n    data: |\n      Project name:{{$project_name}}\n  - path: pkg/{{printf `%s-%s` $project_name `data`}}/some_file.txt\n    data: |\n      {{$project_name}}\n\ncmd:\n  - \"cat internal/{{$project_name}}.txt\"\n  - exec: ls\n    dir: .\n    args: [ -l ]\n  - exec: tree\n```\n\n```console\n% progen -v\n2023-01-22 13:03:58\tINFO\tcurrent working direcotry: /Users/user_1/GoProjects/service\n2023-02-05 14:47:25\tINFO\tapplication working directory: /Users/user_1/GoProjects/service\n2023-02-05 14:47:25\tINFO\tconfiguration file: progen.yaml\n2023-02-05 14:47:25\tINFO\tfile process: internal/SOME_PROJECT.txt\n2023-02-05 14:47:25\tINFO\tfile process: pkg/SOME_PROJECT-data/some_file.txt\n2023-02-05 14:47:25\tINFO\tdir created: api/SOME_PROJECT/v1\n2023-02-05 14:47:25\tINFO\tdir created: internal/some/file/path\n2023-02-05 14:47:25\tINFO\tdir created: pkg/SOME_PROJECT-data\n2023-02-05 14:47:25\tINFO\tfile saved: internal/SOME_PROJECT.txt\n2023-02-05 14:47:25\tINFO\tfile saved: pkg/SOME_PROJECT-data/some_file.txt\n2023-02-05 14:47:25\tINFO\texecute [dir: .]: cat internal/SOME_PROJECT.txt\nout:\nProject name:SOME_PROJECT\n\n2023-02-05 14:47:25\tINFO\texecute [dir: .]: ls -l\nout:\ntotal 0\ndrwxr-xr-x  3 19798572  646495703   96 Feb  5 14:47 api\ndrwxr-xr-x  4 19798572  646495703  128 Feb  5 14:47 internal\ndrwxr-xr-x  3 19798572  646495703   96 Feb  5 14:47 pkg\n\n2023-02-05 14:47:25\tINFO\texecute [dir: .]: tree\nout:\n.\n├── api\n│   └── SOME_PROJECT\n│       └── v1\n├── internal\n│   ├── SOME_PROJECT.txt\n│   └── some\n│       └── file\n│           └── path\n├── pkg\n│   └── SOME_PROJECT-data\n│       └── some_file.txt\n└── progen.yml\n\n9 directories, 2 files\n```\n\n#### Custom template functions\n\n| Function          |             args             | Description                                                                                                                                                                       |\n|:------------------|:----------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `random`          |\n| `random.Alpha`    |         length `int`         | Generates a random alphabetical `(A-Z, a-z)` string of a desired length.                                                                                                          | \n| `random.Num`      |         length `int`         | Generates a random numeric `(0-9)` string of a desired length.                                                                                                                    | \n| `random.AlphaNum` |         length `int`         | Generates a random alphanumeric `(0-9, A-Z, a-z)` string of a desired length.                                                                                                     |\n| `random.ASCII`    |         length `int`         | Generates a random string of a desired length, containing the set of printable characters from the 7-bit ASCII set. This includes space (’ ‘), but no other whitespace character. |\n| `slice`           |                              |                                                                                                                                                                                   |\n| `slice.New`       |       N `any` elements       | Create new slice from any numbers of elements \u003cbr/\u003e(`{ $element := slice.New \"a\" 1 \"b\" }}`)                                                                                       |\n| `slice.Append`    | slice,\u003cbr/\u003e N `any` elements | Add element to exists slice \u003cbr/\u003e(`{{ $element := slice.Append $element \"b\"}}`)                                                                                                   |\n| `strings`         |                              |                                                                                                                                                                                   |\n| `strings.Replace` |  s, old, new string, n int   | Replace returns a copy of the string `s` with `old` replaced by `new` (work the same as `strings.Replace` from `stdlib`).                                                         |\n\nCustom template's functions added as custom arguments to the template\n[function map](https://pkg.go.dev/text/template#hdr-Functions).\n\n---\n\n## Flags\n\n### \u003ca name=\"config_file\"\u003e\u003ca/\u003eConfiguration file\n\nBy default `progen` try to find `progen.yml` file for execution. `-f` flag specify custom configuration file location:\n\n```console\nprogen -f custom_conf.yaml\n```\n\nInstead of specifying a config file, you can pass a single configuration file in the pipe the file in via `STDIN`.\nTo pipe a `progen.yml` from `STDIN`:\n\n```console\nprogen - \u003c progen.yml\n```\n\nor\n\n```console\ncat progen.yml | progen -\n```\n\nIf you use `STDIN`  the system ignores any `-f` option.\n\n**Example** (get `progen.yml` from gitlab repository with replacing [text/template](https://pkg.go.dev/text/template)\nvariables using `-tvar` flag):\n\n```console\ncurl -H PRIVATE-TOKEN:token https://gitlab.some.com/api/v4/projects/13/repository/files/shared%2Fteplates%2Fsimple%2Fprogen.yml/raw\\?ref\\=feature/templates | progen -v -dr -tvar=.vars.GOPROXY=some_proxy -\n```\n\n### \u003ca name=\"print_err_trace\"\u003e\u003ca/\u003ePrint error stack trace\n\nTo print a stack trace of the error which occurred during execution of the `cli`,\nuse `-errtrace` flag:\n\n```console\n% progen -f ../not_exists_config.yml\n2023-03-04 15:05:54\tFATAL\tread config: config file:\n    github.com/kozmod/progen/internal/config.(*Reader).Read\n        /Users/some_user/projects/progen/internal/config/reader.go:39\n  - open ../not_exists_config.yml: no such file or directory\n```\n\n### \u003ca name=\"dry_run\"\u003e\u003ca/\u003eDry Run mode\n\nThe `-dr` flag uses to execute configuration in dry run mod. All `action` will be executed without applying.\n\n```yaml\n## progen.yml\n\n# {{$project_name := \"SOME_PROJECT\"}}\ndirs:\n  - api/{{ $project_name }}/v1 # apply template variables, but not create directories on 'dry run'\ncmd:\n  - tree # not execute on 'dry run' mode\n\nfiles:\n  - path: api/v1/some_file.txt # apply template variables and only printing the file's data\n    data: |\n      some file data data fot project: {{ $project_name }}\n```\n\n```console\n% progen -v -dr\n2023-03-07 07:57:52\tINFO\tapplication working directory: /Users/user_1/GoProjects/service\n2023-03-07 07:57:52\tINFO\tconfiguration file: progen.yml\n2023-03-07 07:57:52\tINFO\tfile process: api/v1/some_file.txt\n2023-03-07 07:57:52\tINFO\tdir created: api/SOME_PROJECT/v1\n2023-03-07 07:57:52\tINFO\texecute [dir: .]: tree\n2023-03-07 07:57:52\tINFO\tsave file: create dir [api/v1] to store file [%!s(func() string=0x136ecc0)]\n2023-03-07 07:57:52\tINFO\tfile saved [path: api/v1/some_file.txt]:\nsome file data data fot project: SOME_PROJECT\n2023-03-07 07:57:52\tINFO\texecution time: 3.69506ms\n```\n\n### \u003ca name=\"awd\"\u003e\u003ca/\u003eApplication working directory\n\nThe `-awd` flag uses for setting application working directory.\nAll `paths` declared in the config file are calculated considering the root directory.\n\n### \u003ca name=\"print_config\"\u003e\u003ca/\u003ePrint configuration file\n\nTo print the configuration file after processing as [text/template](https://pkg.go.dev/text/template),\nuse `-printconf` flag:\n\n```yaml\n## progen.yml\n\nvars:\n  some_data: VARS_SOME_DATA\n\n# {{- $var_1 := random.AlphaNum 15}}\n#  {{- $var_2 := \"echo some_%s\"}}\ncmd:\n  - echo {{ $var_1 }}\n  - \"{{ printf $var_2  `value` }}\"\n  - echo {{ .vars.some_data }}\n```\n\n```console\n% progen -printconf\n2023-03-04 14:57:43\tINFO\tpreprocessed config:\nvars:\n  some_data: VARS_SOME_DATA\n\n#\n#\ncmd:\n  - echo AHNsgyzVxRqeqLt\n  - \"echo some_value\"\n  - echo VARS_SOME_DATA\n```\n\n### \u003ca name=\"files_preprocessing\"\u003e\u003ca/\u003eFiles preprocessing\n\nBy default, all files loading to the memory and process as [text/template](https://pkg.go.dev/text/template) before\nsaving to a file system.\nTo change this behavior, set `-pf=false`.\n\n```console\n% progen -v -dr -f progen.yml\n2023-02-05 14:15:54\tINFO\tapplication working directory: /Users/user_1/GoProjects/service\n2023-02-05 14:15:54\tINFO\tconfiguration file: progen.yml\n2023-02-05 14:15:54\tINFO\tfile process: api/v1/some_file.txt\n2023-02-05 14:15:54\tINFO\tdir created: api/SOME_PROJECT/v1\n2023-02-05 14:15:54\tINFO\texecute cmd: chmod -R 777 api/v1\n2023-02-05 14:15:54\tINFO\tsave file: create dir [api/v1] to store file [some_file.txt]\n2023-02-05 14:15:54\tINFO\tfile saved [path: api/v1/some_file.txt]:\nsome file data data fot project: SOME_PROJECT\n```\n\n### \u003ca name=\"tvar\"\u003e\u003ca/\u003eTemplate variables\n\nAny part of template variable tree can be overrides using `-tvar` flag\n\n```yaml\n## progen.yml\n\n## `text/template` variables declaration 👇\n# {{$project_name := \"SOME_PROJECT\"}}\n\n## unmapped section (not `dirs`, `files`, `cmd`, `http`) can be use as template variables\nvars:\n  file_path: some/file/path\n  file_path_2: some/file/path_2\n\ndirs:\n  - api/{{$project_name}}/v1 # used from `text/template` variables\n  - internal/{{.vars.file_path}} # used from `vars` section\n  - internal/{{.vars.file_path_2}} # used overridden `vars` which set through args (-tvar=.vars.file_path 2=override path)\n```\n\n```console\n% progen -v -dr -tvar=.vars.file_path_2=overrided_path\n2023-02-05 14:51:38\tINFO\tapplication working directory: /Users/user_1/GoProjects/service\n2023-02-05 14:51:38\tINFO\tconfiguration file: progen.yml\n2023-02-05 14:51:38\tINFO\tdir created: api/SOME_PROJECT/v1\n2023-02-05 14:51:38\tINFO\tdir created: internal/some/file/path\n2023-02-05 14:51:38\tINFO\tdir created: internal/overrided_path\n```\n\n### \u003ca name=\"skip_actions\"\u003e\u003ca/\u003eSkip `actions`\n\nSet `-skip` flag to skip any `action` (only root actions: `cmd`, `files`, `dirs`). Value of the flag is a regular\nexpression.\n\n```yaml\n## progen.yml\n\ndirs:\n  - api/v1\ncmd:\n  - chmod -R 777 api/v1\ndirs1:\n  - api/v2\ncmd1:\n  - chmod -R 777 api/v2\ndirs2:\n  - api/v3\ncmd2:\n  - chmod -R 777 api/v3 \n```\n\n```console\n% progen -v -dr -f progen.yml -skip=^dirs$ -skip=cmd.+ \n2023-02-05 14:18:11\tINFO\tapplication working directory: /Users/user_1/GoProjects/service\n2023-02-05 14:18:11\tINFO\tconfiguration file: progen.yml\n2023-02-05 14:18:11\tINFO\taction will be skipped: [cmd1]\n2023-02-05 14:18:11\tINFO\taction will be skipped: [cmd2]\n2023-02-05 14:18:11\tINFO\taction will be skipped: [dirs]\n2023-02-05 14:18:11\tINFO\texecute cmd: chmod -R 777 api/v1\n2023-02-05 14:18:11\tINFO\tdir created: api/v2\n2023-02-05 14:18:11\tINFO\tdir created: api/v3\n```\n\n---\n\n## Actions and tags\n\n### \u003ca name=\"http_client\"\u003e\u003c/a\u003eHttp Client\n\nHTTP client configuration\n\n```yaml\n## progen.yml\n\nsettings:\n  http:\n    debug: false\n    base_url: https://gitlab.repo_2.com/api/v4/projects/5/repository/files/\n    headers:\n      PRIVATE-TOKEN: glpat-SOME_TOKEN\n    query_params:\n      PARAM_1: Val_1\n```\n\n### \u003ca name=\"groups_of_actions\"\u003e\u003c/a\u003eGroups of actions\n\nAll actions execute in declaration order in the config file and can be union to groups.\nAll actions in `manual` groups will be skipped during execution process.\n\n```yaml\nsettings:\n  groups:\n    - name: group1\n      actions: [ cmd, cmd_2 ]\n      manual: true\n    - name: group2\n      actions: [ cmd_2 ]\n      manual: true\n\ncmd:\n  - echo CMD_1\n\ncmd_2:\n  - echo CMD_2\n\ncmd_3:\n  - echo CMD_3\n\ncmd_4:\n  - echo CMD_4\n\n```\n\n```console\n% progen -v\n2024-02-05 23:08:21     INFO    application working directory: /Users/user_1/GoProjects/service\n2024-02-05 23:08:21     INFO    configuration file: progen.yml\n2024-02-05 23:08:21     INFO    manual actions will be skipped: [cmd, cmd_2]\n2024-02-05 23:08:21     INFO    execute [dir: .]: echo CMD_3\nout:\nCMD_3\n\n2024-02-05 23:08:21     INFO    execute [dir: .]: echo CMD_4\nout:\nCMD_4\n\n2024-02-05 23:08:21     INFO    execution time: 7.916615ms\n```\n\nActions in `manual` groups execute using `gp` flag (all action execute only once independent on declaration's quantity\nin different groups).\n\n```console\n% progen -v -gp=group1 -gp=group2\n2024-02-05 23:19:50     INFO    application working directory: /Users/user_1/GoProjects/service\n2024-02-05 23:19:50     INFO    configuration file: progen.yml\n2024-02-05 23:19:50     INFO    groups will be execute: [group1, group2]\n2024-02-05 23:19:50     INFO    execute [dir: .]: echo CMD_1\nout:\nCMD_1\n\n2024-02-05 23:19:50     INFO    execute [dir: .]: echo CMD_2\nout:\nCMD_2\n\n2024-02-05 23:19:50     INFO    execution time: 7.192257ms\n\n```\n\n### Files\n\nFile's content can be declared in configuration file (`files.data` tag) or\ncan be received from local (`files.local`) or remote (`files.get`) storage.\nAny file's content uses as [text/template](https://pkg.go.dev/text/template)\nand configuration's `yaml` tag tree applies as template variables.\n\n```yaml\n## progen.yml\n\n# settings of the cli\nsettings:\n  # common http client configuration  \n  http:\n    debug: false\n    base_url: https://gitlab.repo_2.com/api/v4/projects/5/repository/files/\n    headers:\n      PRIVATE-TOKEN: glpat-SOME_TOKEN\n\n# {{$project_name := \"SOME_PROJECT\"}}\n# {{$gitlab_suffix := \"/raw?ref=some_branch\"}}\n\nfiles:\n  - path: files/Readme.md\n    data: |\n      Project name: {{$project_name}}\n\n  - path: files/.gitignore\n    # copy file from location\n    local: some/dir/.gitignore.gotmpl\n\n  - path: files/.editorconfig\n    get:\n      url: \"{{printf `%s%s` `.editorconfig` $gitlab_suffix}}\"\n\n  - path: files/.gitlab-ci.yml\n    # GET file from remote storage\n    get:\n      # reset URL which set in http client configuration (http.base_url)\n      url: \"https://some_file_server.com/files/.gitlab-ci.yml\"\n      # reset headers of common http client configuration (http.headers)\n      headers:\n        some_header: header\n      query_params:\n        PARAM_1: Val_1\n\n  - path: files/Dockerfile\n    # GET file from remote storage (using common http client config)\n    get:\n      # reuse `base` URL of common http client config (http.base_url)\n      url: Dockerfile/raw?ref=feature/project_templates\"\n```\n\n```console\n% progen -v\n2023-02-05 14:47:25\tINFO\tcurrent working direcotry: /Users/user_1/GoProjects/service\n2023-02-05 14:47:25\tINFO\tconfiguration file: progen.yaml\n2023-02-05 14:47:25\tINFO\tfile process: files/Readme.md\n2023-02-05 14:47:25\tINFO\tfile process: files/.gitignore\n2023-02-05 14:47:25\tINFO\tfile process: files/.editorconfig\n2023-02-05 14:47:25\tINFO\tfile process: files/.gitlab-ci.yml\n2023-02-05 14:47:25\tINFO\tfile process: files/Dockerfile\n...\n2023-02-05 14:47:25\tINFO\tfile saved: files/Readme.md\n2023-02-05 14:47:25\tINFO\tfile saved: files/.gitignore\n2023-02-05 14:47:25\tINFO\tfile saved: files/.editorconfig\n2023-02-05 14:47:25\tINFO\tfile saved: files/.gitlab-ci.yml\n2023-02-05 14:47:25\tINFO\tfile saved: files/Dockerfile\n...\n```\n\n### Commands\n\nExecution commands process configured by specifying __commands working directory__ and commands definition.\nDefault value of __commands working directory__ (`dir` tag) is `.`.\n__Commands working directory__ calculate from the __application working directory__.\n\n```yaml\n## progen.yml\n\ncmd:\n  - exec: ls -l\n    args: [ - l ]\n    dir: .github/workflows\n  - exec: tree\n    args: [ -L, 1 ]\n```\n\n```console\n% progen -v \n2023-02-02 22:18:20\tINFO\tapplication working directory: /Users/user_1/GoProjects/progen\n2023-02-02 22:18:20\tINFO\tconfiguration read: progen.yml\n2023-02-02 22:18:20\tINFO\texecute [dir: .github/workflows]: ls -l\nout:\ntotal 16\n-rw-r--r--  1 19798572  646495703  762 Feb  1 09:15 release.yml\n-rw-r--r--  1 19798572  646495703  377 Jan 24 20:06 test.yml\n\n2023-02-02 22:18:20\tINFO\texecute [dir: .]: tree -L 1\nout:\n.\n├── LICENSE\n├── Makefile\n├── Readme.md\n├── go.mod\n├── go.sum\n├── internal\n├── main.go\n└── tmp\n\n2 directories, 6 files\n```\n\n`cmd` action maintains \"short\" declaration syntax\n\n```yaml\n## progen.yml\n\ncmd:\n  - pwd\n  - ls -a\n```\n\n```console\n% progen -v -dr\n2023-02-15 17:56:58\tINFO\tapplication working directory: /Users/user_1/GoProjects/progen\n2023-02-15 17:56:58\tINFO\tconfiguration file: short.yml\n2023-02-15 17:56:58\tINFO\texecute [dir: .]: pwd\n2023-02-15 17:56:58\tINFO\texecute [dir: .]: ls -a\n```\n\n### \u003ca name=\"fs\"\u003e\u003c/a\u003eFile System\n\n`fs` section configure execution [text/template](https://pkg.go.dev/text/template) on a directories tree.\nAll files in the `tree` processed as `template`. Files and directories names also could be configured as templates.\n\n```yaml\n## progen.yml\n\nvar_d: VAR_d\nvar_f: VAR_f\n\ncmd:\n  - cp -a ../asserts/. ../out/\n  - exec: tree\n    dir: .\n\nfs:\n  - test_dir\n  - test_dir_2\n\ncmd_finish:\n  - exec: tree\n    dir: .\n```\n\n```console\n% progen -v -awd=out -f ../progen.yml\n2023-02-12 14:01:45\tINFO\tapplication working directory: /Users/user_1/GoProjects/progen\n2023-02-12 14:01:45\tINFO\tconfiguration file: ../progen.yml\n2023-02-12 14:01:45\tINFO\texecute [dir: .]: cp -a ../asserts/. ../out/\n2023-02-12 14:01:45\tINFO\texecute [dir: .]: tree\nout:\n.\n├── test_dir\n│   ├── file1\n│   └── {{ .var_d }}\n│       └── {{ .var_f }}\n└── test_dir_2\n    ├── file1\n    └── {{ .var_d }}\n        └── {{ .var_f }}\n\n4 directories, 4 files\n\n2023-02-12 14:01:45\tINFO\tdir created: test_dir/VAR_d\n2023-02-12 14:01:45\tINFO\tfile saved: test_dir/file1\n2023-02-12 14:01:45\tINFO\tfile saved: test_dir/VAR_d/VAR_f\n2023-02-12 14:01:45\tINFO\tdir created: test_dir_2/VAR_d\n2023-02-12 14:01:45\tINFO\tfile saved: test_dir_2/file1\n2023-02-12 14:01:45\tINFO\tfile saved: test_dir_2/VAR_d/VAR_f\n2023-02-12 14:01:45\tINFO\tfs: remove: test_dir_2/{{ .var_d }}/{{ .var_f }}\n2023-02-12 14:01:45\tINFO\tfs: remove: test_dir_2/{{ .var_d }}\n2023-02-12 14:01:45\tINFO\texecute [dir: .]: tree\nout:\n.\n├── test_dir\n│   ├── VAR_d\n│   │   └── VAR_f\n│   └── file1\n└── test_dir_2\n    ├── VAR_d\n    │   └── VAR_f\n    └── file1\n```\n\n### \u003ca name=\"rm\"\u003e\u003c/a\u003eRm\n\n`rm` use to remove files, directories or files inside a directory.\n\n```yaml\nrm:\n  # remove the dir\n  - some_dir\n  # remove all files in the dir\n  - some_dir_2/*\n  # remove the file\n  - some_dir_3/file.txt\n```\n\n```console\n% progen -v\n2024-02-09 22:50:51     INFO    application working directory: /Users/user_1/GoProjects/progen\n2023-02-12 14:01:45     INFO    configuration file: progen.yml\n2024-02-09 22:50:51     INFO    rm: some_dir\n2024-02-09 22:50:51     INFO    rm all: some_dir_2/*\n2024-02-09 22:50:51     INFO    rm: some_dir_3/file.txt\n2024-02-09 22:50:51     INFO    execution time: 350.149µs\n```\n\n---\n\n### \u003ca name=\"lib_usage\"\u003e\u003ca/\u003eLib\n\nTo use `progen` for building custom generator based on `go` language, imports `pkg/core` package\nand implements required algorithm:\n```golang\npackage main\n\nimport (\n\t\"log\"\n\t\"testing/fstest\"\n\n\t\"github.com/kozmod/progen/pkg/core\"\n)\n\nvar fs = fstest.MapFS{\n\t\"1\": {\n\t\tData: []byte(\"aaaa\"),\n\t},\n}\n\nfunc main() {\n\t// Parse default config base on flags\n\tc, err := core.ParseFlags()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tvar e core.Engin\n\n\t// add actions\n\te.AddActions(\n\t\t// create files actions\n\t\tcore.FilesAction(\n\t\t\t\"create_file\",\n\t\t\tcore.File{Path: \"./xx/1\", Data: []byte(\"file_1\")},\n\t\t\tcore.File{Path: \"./xx/2\", Data: []byte(\"file_2\")},\n\t\t\tcore.File{Path: \"./xx/rm_1\", Data: []byte(\"file_rm\")},\n\t\t).WithPriority(1),\n\t\t// rm actions\n\t\tcore.RmAction(\n\t\t\t\"rm\",\n\t\t\t\"./xx/rm_1\",\n\t\t).WithPriority(2),\n\t)\n\te.AddActions(\n\t\t// create file system action\n\t\tcore.FsSaveAction(\n\t\t\t\"fs_1\",\n\t\t\tcore.TargetFs{\n\t\t\t\tTargetDir: \"./xx/fs\",\n\t\t\t\tFs:        fs, // any [io/fs.FS] (from local system, embed, etc.)\n\t\t\t},\n\t\t).WithPriority(3),\n\t\t\n\t\t// cmd action\n\t\tcore.CmdAction(\n\t\t\t\"tree_1\",\n\t\t\tcore.Cmd{\n\t\t\t\tCmd: \"tree\",\n\t\t\t\tDir: \"./xx\",\n\t\t\t},\n\t\t).WithPriority(4),\n\t)\n\n\terr = e.Run(c)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n\n```\n```console\n% go build .\n% ./tmp -v  \n2024-12-11 10:16:17     INFO    action is going to be execute ('priopiry':'name')['1':'create_file','2':'rm','3':'fs_1','4':'tree_1']\n2024-12-11 10:16:17     INFO    file saved: xx/1\n2024-12-11 10:16:17     INFO    file saved: xx/2\n2024-12-11 10:16:17     INFO    file saved: xx/rm_1\n2024-12-11 10:16:17     INFO    rm: ./xx/rm_1\n2024-12-11 10:16:17     INFO    dir created: xx/fs\n2024-12-11 10:16:17     INFO    file saved: xx/fs/1\n2024-12-11 10:16:17     INFO    execute [dir: ./xx]: tree\nout:\n.\n├── 1\n├── 2\n└── fs\n    └── 1\n\n1 directory, 3 files\n```\n\n---\n\n### Examples\n\n[progen-example](https://github.com/kozmod/progen-examples) repository contains useful examples of usage cli\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkozmod%2Fprogen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkozmod%2Fprogen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkozmod%2Fprogen/lists"}