{"id":22861906,"url":"https://github.com/escapace/manage","last_synced_at":"2025-04-30T21:44:03.419Z","repository":{"id":35672691,"uuid":"39948167","full_name":"escapace/manage","owner":"escapace","description":"framework for building modular Bash applications","archived":false,"fork":false,"pushed_at":"2024-09-19T14:53:31.000Z","size":637,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"trunk","last_synced_at":"2025-03-30T20:11:50.120Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/escapace.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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":"2015-07-30T11:57:39.000Z","updated_at":"2024-10-22T11:41:44.000Z","dependencies_parsed_at":"2024-12-13T10:11:53.758Z","dependency_job_id":"0d38346b-b260-452e-acc7-9a0cf43bdc51","html_url":"https://github.com/escapace/manage","commit_stats":null,"previous_names":[],"tags_count":59,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/escapace%2Fmanage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/escapace%2Fmanage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/escapace%2Fmanage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/escapace%2Fmanage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/escapace","download_url":"https://codeload.github.com/escapace/manage/tar.gz/refs/heads/trunk","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251789225,"owners_count":21644077,"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":["bash","framework"],"created_at":"2024-12-13T10:11:32.470Z","updated_at":"2025-04-30T21:44:03.402Z","avatar_url":"https://github.com/escapace.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# manage\n\n[![build status][2]][1]\n[![license][3]]()\n\n`manage` is an MPLv2 licensed framework for building modular Bash\napplications.\n\n## Table of Contents\n\n-   [Usage](#usage)\n    -   [Setup](#setup)\n    -   [Commands and Modules](#commands-and-modules)\n    -   [Built-in statements](#built-in-statements)\n    -   [Utility Library](#utility-library)\n    -   [Remote Modules](#remote-modules)\n-   [Acknowledgements](#acknowledgements)\n-   [License](#license)\n\n## Usage\n\nIn this example, we’ll use `manage` as a submodule. We’ll go through\nthe setup process; learn the distinction between commands and modules;\nand describe built-in statements.\n\n### Setup\n\nLet’s make a temporary directory, initialize a git project and add a\ndirectory to it (vendor, in this case).\n\n```bash\n$ mkdir tmp\n$ cd tmp\n$ mkdir vendor\n```\n\nAdd `manage` as a submodule\n\n```bash\n$ git submodule add https://github.com/escapace/manage vendor/manage\n```\n\nRun the initialization script\n\n```bash\n$ ./vendor/manage/manage init\n```\n\nThis will set up directories inside `tmp` as follows\n\n```bash\nINFO Creating scripts directory /path/to/tmp/scripts\nINFO Creating modules directory /path/to/tmp/scripts/modules\n```\n\nRunning `ls -a` in `tmp`, we should now get\n\n```bash\n.  ..  scripts  manage  .manage.yml\n```\n\nNote that these paths are customizable in the `.manage.yml` file.\n\n### Commands and Modules\n\nCommands are scripts local to the project. Modules are reusable bash functions\nthat can be imported from commands in local and remote projects.\n\n#### Commands\n\n-   Contain [`@dependency`][29] [`@description`][30] and [`@import`][31]\n    statements\n-   When importing modules, need to prefix them with an underscore\n\n#### Modules\n\n-   Contain only [`@import`][31] statements\n-   Must have only 1 function\n-   File name must be the same as the bash function name it exposes\n-   Must not prefix imported modules with an underscore\n-   Should be placed in `scripts/modules/arbitrary-directory/moduleName`\n\n### Built-in statements\n\n#### @description\n\n```sh\n# @description capitalize and print string\n```\n\nProvides a short description of a script which will be logged when `./manage` is called\n\n#### @dependency\n\n```bash\n# @dependency docker\n```\n\nChecks whether executable with given name exists in **PATH**\n\n#### @import\n\n```bash\n# @import github.com/escapace/stack-tools download/downloadPacker\n```\n\nImport a module from import path.\n\n-   Modules from manage utility library such as `array/join`\n-   Local modules in `scripts/modules` directory\n-   Remote modules such as `github.com/escapace/stack-tools download/downloadPacker`\n\n### Utility Library\n\nManage contains utility modules for Bash, resembling those of lodash.\nUtility module groups include\n\n-   [array][5]\n-   [console][6]\n-   [lang][7]\n-   [manage][8]\n-   [path][9]\n-   [string][10]\n\nLet’s import and use one of these. In `scripts` there is a file called\n`hello`. It already uses `warn` and `error` modules\n\n```bash\n# @import console/warn\n# @import console/error\n```\n\nImported modules should be prefixed with underscore, hence\n\n```bash\nif (( $1 == 0 ))\nthen\n    _ warn \"Exiting.\"\nelse\n    _ error \"An error with exit code \\\"$1\\\" has occurred.\"\nfi\n```\n\nWe import `string/capitalize`, which, not surprisingly, capitalizes a\nstring.\n\n```bash\n# @import string/capitalize\n```\n\nThen we add the following to `main ()`\n\n```bash\nlocal string=\"lorem\"\n_ capitalize \"${string}\"\n```\n\nNow, if we run\n\n```bash\n$ ./manage hello\n```\n\nThe result will be\n\n    Hello World!\n    Script name: hello\n    Caller name: manage\n    Repository : path/to/tmp\n    PWD        : path/to/tmp\n    Argument 1 :\n    Argument 2 :\n    Argument 3 :\n    Lorem\n    WARN Exiting.\n\nNotice on line 9, “lorem” is capitalized to “Lorem”.\n\n### Remote Modules\n\nAn import path can describe how to obtain the module source code from a GitHub\nrepository. The GitHub repository should have at least one signed version tag\n(like v1.8.5). Say we want to import a manage module from the\n[escapace/stack-tools][11] repository that automates the download and\nverification of Hashicorp’s [Terraform][12].\n\nIn order to verify the [escapace/stack-tools][11] repository, we need to have\nthe escapace public key.\n\n```bash\n$ gpg2 --keyserver ha.pool.sks-keyservers.net --recv-key 13F26F82E955B8B8CE469054F29CCEBC83FD4525\n```\n\nNow, we can import the script by adding the following line to our `hello` file\nin `scripts`\n\n```bash\n# @import github.com/escapace/stack-tools download/downloadTerraform\n```\n\nThen run\n\n```bash\n$ ./manage hello\n```\n\nThis will execute the script and create a `.manage_modules` directory\ncontaining our imports. If we run `ls -a` in `tmp`, we should get\n\n```bash\n.  .. .git  .manage_modules  scripts  vendor  .gitmodules  manage  .manage.yml\n```\n\n`vendor/terraform` now contains HashiCorp’s Terraform, which is ready\nfor usage.\n\n## Acknowledgements\n\nOur thanks go out to the developers and organizations who have directly and\nindirectly contributed to this project.\n\n-   [Jeremy Cantrell][14], [bashful][13] collection of libraries that simplify writing bash\n    scripts\n-   [Justin Dorfman][16] and [Joshua Mervine][17], [shml][15] terminal style framework\n-   [Christian Couder][19], [Mathias Lafeldt][20] and contributors, [sharness][18] test library\n\n## License\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the MPL 2.0.\n\nThis program uses third-party libraries or other resources that may be\ndistributed under different licenses. Please refer to the specific\nfiles and/or packages for more detailed information about the authors,\ncopyright notices, and licenses.\n\n[1]: https://travis-ci.org/escapace/manage\n\n[2]: https://secure.travis-ci.org/escapace/manage.png\n\n[3]: https://img.shields.io/badge/license-Mozilla%20Public%20License%20Version%202.0-blue.svg\n\n[4]: #built-in-statements\n\n[5]: https://github.com/escapace/manage/tree/trunk/modules/array\n\n[6]: https://github.com/escapace/manage/tree/trunk/modules/console\n\n[7]: https://github.com/escapace/manage/tree/trunk/modules/lang\n\n[8]: https://github.com/escapace/manage/tree/trunk/modules/manage\n\n[9]: https://github.com/escapace/manage/tree/trunk/modules/path\n\n[10]: https://github.com/escapace/manage/tree/trunk/modules/string\n\n[11]: https://github.com/escapace/stack-tools\n\n[12]: https://www.terraform.io/\n\n[13]: https://github.com/jmcantrell/bashful\n\n[14]: https://github.com/jmcantrell\n\n[15]: https://github.com/MaxCDN/shml\n\n[16]: https://github.com/jdorfman\n\n[17]: https://github.com/jmervine\n\n[18]: https://github.com/chriscool/sharness\n\n[19]: https://github.com/chriscool\n\n[20]: https://twitter.com/mlafeldt\n\n[22]: #usage\n\n[23]: #setup\n\n[24]: #commands-and-modules\n\n[25]: #utility-library\n\n[26]: #remote-modules\n\n[27]: #acknowledgements\n\n[28]: #license\n\n[29]: #dependency\n\n[30]: #description\n\n[31]: #import\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fescapace%2Fmanage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fescapace%2Fmanage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fescapace%2Fmanage/lists"}