{"id":18464157,"url":"https://github.com/rydnr/dry-wit","last_synced_at":"2025-04-08T08:31:02.001Z","repository":{"id":63097030,"uuid":"9855254","full_name":"rydnr/dry-wit","owner":"rydnr","description":"Bash framework to improve maintainability and readability of shell scripts.","archived":false,"fork":false,"pushed_at":"2024-10-28T17:23:57.000Z","size":1882,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-28T18:47:36.013Z","etag":null,"topics":["bash","shell"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rydnr.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":"2013-05-04T14:38:04.000Z","updated_at":"2024-10-28T17:24:00.000Z","dependencies_parsed_at":"2024-05-04T16:28:56.281Z","dependency_job_id":"427b96fe-041f-47be-8b0a-ce3a93ad8a6e","html_url":"https://github.com/rydnr/dry-wit","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rydnr%2Fdry-wit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rydnr%2Fdry-wit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rydnr%2Fdry-wit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rydnr%2Fdry-wit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rydnr","download_url":"https://codeload.github.com/rydnr/dry-wit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223310589,"owners_count":17124246,"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","shell"],"created_at":"2024-11-06T09:09:00.631Z","updated_at":"2024-11-06T09:09:01.340Z","avatar_url":"https://github.com/rydnr.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dry-wit\n\nThis is dry-wit, a framework for bash scripts.\n\nThis project is useful when writing new scripts. It provides a common\nlayout and a toolbox of functions to help writing shell scripts from\nscratch.\n\nSince Bash is an interpreted language, you can review the contents of\ndry-wit yourself.\n\nIt comes with a number of [modules](https://github.com/rydnr/dry-wit/tree/main/src/modules \"modules\").\n\n## Usage\n\n- Use this shebang in your scripts.\n\n``` sh\n#!/usr/bin/env dry-wit\n```\n\n- Write the only mandatory function `main()`\n\nThe `main()` function is the starting point of your script. You don't need to care about anything but the funcional requirements of your script.\n\n## Examples\n\nYou can check other dry-wit scripts as a reference. For example, \u003chttps://github.com/rydnr/update-sha256-in-nix-flake/tree/main/src/update-sha256-in-nix-flake.sh\u003e.\n\n## Installation for Nix users\n\nIf you are a Nix user, you can create your own scripts using dry-wit and package them as Nix flakes too.\n\nHere's a template you can use, assuming the script is in a git repository under the `src/` subfolder.\n\n``` nix\n#\n# Sample flake for a dry-wit script.\n#\n{\n  description = \"A dry-wit script\";\n  inputs = rec {\n    flake-utils.url = \"github:numtide/flake-utils/v1.0.0\";\n    nixos.url = \"github:NixOS/nixpkgs/nixos-23.05\";\n    dry-wit = {\n      inputs.flake-utils.follows = \"flake-utils\";\n      inputs.nixos.follows = \"nixos\";\n      url = \"github:rydnr/dry-wit/3.0.3?dir=nix\";\n    };\n  };\n  outputs = inputs:\n    with inputs;\n    let\n      defaultSystems = flake-utils.lib.defaultSystems;\n      supportedSystems = if builtins.elem \"armv6l-linux\" defaultSystems then\n        defaultSystems\n      else\n        defaultSystems ++ [ \"armv6l-linux\" ];\n    in flake-utils.lib.eachSystem supportedSystems (system:\n      let\n        org = \"[your-user]\";\n        repo = \"[the-script-repo]\";\n        pname = \"${org}-${repo}\";\n        version = \"0.0.1\";\n        pkgs = import nixos { inherit system; };\n        description =\n          \"A dry-wit script\";\n        license = pkgs.lib.licenses.gpl3;\n        homepage = \"https://github.com/${org}/${repo}\";\n        maintainers = [ \"rydnr \u003cgithub@acm-sl.org\u003e\" ];\n        my-script-for = { dry-wit }:\n          pkgs.stdenv.mkDerivation rec {\n            inherit pname version;\n            src = ../.;\n            buildInputs = [ dry-wit ];\n            phases = [ \"unpackPhase\" \"installPhase\" ];\n\n            installPhase = ''\n              mkdir -p $out/bin\n              cp -r src/* $out/bin\n              chmod +x $out/bin/*\n              cp README.md LICENSE $out/\n              for f in $out/bin/*.sh; do\n                substituteInPlace $f \\\n                  --replace \"#!/usr/bin/env dry-wit\" \"#!/usr/bin/env ${dry-wit}/dry-wit\"\n              done\n            '';\n\n            meta = with pkgs.lib; {\n              inherit description homepage license maintainers;\n            };\n          };\n      in rec {\n        defaultPackage = packages.default;\n        packages = rec {\n          default = update-sha256-in-nix-flake-default;\n          my-script-default = my-script-bash5;\n          my-script-bash5 = my-script-for {\n            dry-wit = dry-wit.packages.${system}.dry-wit-bash5;\n          };\n          my-script-zsh = my-script-for {\n            dry-wit = dry-wit.packages.${system}.dry-wit-zsh;\n          };\n          my-script-fish = my-script-for {\n            dry-wit = dry-wit.packages.${system}.dry-wit-fish;\n          };\n        };\n      });\n}\n```\n\n## Nix users\n\nI recommend you to package your script as a flake, so Nix manages the `dry-wit` dependency for you.\nTo do so, check the latest tag of this repository and use it instead of the `[version]` placeholder below.\n\n```nix\n{\n  description = \"[..]\";\n  inputs = rec {\n    [..]\n    dry-wit = {\n      [optional follows]\n      url =\n        \"github:rydnr/dry-wit/[version]?dir=nix\";\n    };\n  };\n  outputs = [..]\n};\n```\n\nThen, in your package, declare `dry-wit` input as a dependency:\n\n``` nix\npropagatedBuildInputs = [ dry-wit ];\n```\n\n`\n## Manual installation\n\nBasically, in order to write dry-wit scripts you'll need to do the following:\n\n- Clone this repository under `~/.dry-wit`:\n\n``` sh\n  git clone https://github.com/rydnr/dry-wit $HOME/.dry-wit\n```\n\n- Add `~/.dry-wit/src` to your PATH:\n\n``` sh\necho 'export PATH=$PATH:$HOME/.dry-wit/src' \u003e\u003e $HOME/.bashrc\n```\n\n### MacOS X\n\nNote for Mac OS X users:\n\n- Your MacOS X might come with an old version of Bash. dry-wit requires Bash 4+. To use a recent version, install homebrew, then bash, and run\n\n``` sh\nchsh -s /usr/local/bin/bash\n```\n\n- Additionally, dry-wit requires the following brew formulae:\n  - greadlink\n  - coreutils\n  - pidof\n  - wget\n\n``` sh\nbrew install greadlink\nbrew install coreutils\nbrew install pidof\nbrew install wget\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frydnr%2Fdry-wit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frydnr%2Fdry-wit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frydnr%2Fdry-wit/lists"}