{"id":18156497,"url":"https://github.com/purag/spackle","last_synced_at":"2025-10-10T11:35:40.265Z","repository":{"id":72350048,"uuid":"89113240","full_name":"purag/spackle","owner":"purag","description":":package: a simple module system for bash scripts","archived":false,"fork":false,"pushed_at":"2017-09-25T00:32:37.000Z","size":11,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-01T07:11:51.688Z","etag":null,"topics":["import","modularization","namespace","shell"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/purag.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2017-04-23T02:52:25.000Z","updated_at":"2017-09-24T23:31:16.000Z","dependencies_parsed_at":"2023-02-28T08:01:40.245Z","dependency_job_id":null,"html_url":"https://github.com/purag/spackle","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/purag/spackle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purag%2Fspackle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purag%2Fspackle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purag%2Fspackle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purag%2Fspackle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/purag","download_url":"https://codeload.github.com/purag/spackle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purag%2Fspackle/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266689100,"owners_count":23969140,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["import","modularization","namespace","shell"],"created_at":"2024-11-02T05:06:40.254Z","updated_at":"2025-10-10T11:35:35.244Z","avatar_url":"https://github.com/purag.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# spackle\nSpackle is a module system for bash scripts.\n\nSpackle will dynamically namespace imported packages, so declared variables and functions will be accessible through the package prefix specified in the imported file.\n\nSpackle also supports package-private declarations using a two-underscore prefix (`__private_varname`).\n\n## Installation\nFirst, place spackle in your project's root:\n\n```bash\nwget https://raw.githubusercontent.com/purag/spackle/master/spackle\n```\n\nThen, source spackle in each of your project's files:\n\n`main.sh`:\n\n```bash\n#!/bin/bash\nsource spackle # or `source ../spackle`, `source ../../spackle`\n```\n\n## Packages\nEach project file can contain one package, which must be declared before importing any other packages. To declare a package, use the `package` command, which takes one argument, the package name:\n\n`test/readme/main.sh`:\n\n```bash\n#!/bin/bash\nsource ../../spackle\npackage myProject\n```\n\nThe package name must be a classic bash identifier (alphanumberic + underscores) since it will be used in identifiers.\n\n**NOTE**: Like C++ namespaces, multiple files can provide the same package.\n\n## Import\nYou include packages by importing the files they're defined in. To do this, use the `import` command, which takes one argument, the path to the file:\n\n`test/readme/main.sh`:\n\n```bash\n#!/bin/bash\nsource ../../spackle\npackage myProject\n\nimport util/helpers.sh\n\necho \"$util__var\" # 'a public variable'\n```\n\n`test/readme/util/helpers.sh`:\n\n```bash\n#!/bin/bash\nsource ../../../spackle\npackage util\n\nvar=\"a public variable\"\n```\n\nAny public variables/functions declared in `util/helpers.sh` will be accessible to files that import it with the prefix `util__`.\n\n### Nested Imports\nIf you import a file which in turn imports a file, the package prefixes compound:\n\n`test/readme/main.sh`:\n\n```bash\n#!/bin/bash\nsource ../../spackle\npackage myProject\n\nimport util/helpers.sh\n\necho \"$util__var\" # 'a public variable'\n\n__trimmed=`util__str__trim \"  hello  \"`\necho \"'$__trimmed'\" # 'hello'\n```\n\n`test/readme/util/helpers.sh`:\n\n```bash\n#!/bin/bash\nsource ../../../spackle\npackage util\n\nimport string/helpers.sh\n```\n\n`test/readme/util/string/helpers.sh`\n\n```bash\n#!/bin/bash\nsource ../../../../spackle\npackage str\n\n# trim leading and trailing whitespace from a string\ntrim () {\n  echo \"$1\" | sed 's/^ *//g' | sed 's/ *$//g'\n}\n```\n\nThis example can be found in `test/readme`.\n\n# TODO(?)\n- add a function to print a dependency tree (using `set` to disable execution)\n- add `import \u003cfile\u003e as \u003crenamed-package\u003e` to rename packages on the fly\n- add `import-private \u003cfile\u003e` to import a file privately (do not expose the imported members to anyone importing the current file)\n- add `import \u003cmember-list\u003e from \u003cfile\u003e` to only import specified members\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurag%2Fspackle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpurag%2Fspackle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurag%2Fspackle/lists"}