{"id":13602819,"url":"https://github.com/xwmx/bask","last_synced_at":"2025-10-19T12:22:28.601Z","repository":{"id":29090057,"uuid":"32619122","full_name":"xwmx/bask","owner":"xwmx","description":"A runner and framework for command-centric Bash scripts.","archived":false,"fork":false,"pushed_at":"2021-07-18T05:18:46.000Z","size":230,"stargazers_count":49,"open_issues_count":1,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-08-16T19:54:18.860Z","etag":null,"topics":["bash","command-line","linux","shell","task-runner","unix"],"latest_commit_sha":null,"homepage":"","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/xwmx.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}},"created_at":"2015-03-21T03:53:36.000Z","updated_at":"2025-06-22T18:18:19.000Z","dependencies_parsed_at":"2022-09-15T04:01:20.043Z","dependency_job_id":null,"html_url":"https://github.com/xwmx/bask","commit_stats":null,"previous_names":["alphabetum/bask"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/xwmx/bask","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xwmx%2Fbask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xwmx%2Fbask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xwmx%2Fbask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xwmx%2Fbask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xwmx","download_url":"https://codeload.github.com/xwmx/bask/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xwmx%2Fbask/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274301907,"owners_count":25260094,"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-09-09T02:00:10.223Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":["bash","command-line","linux","shell","task-runner","unix"],"created_at":"2024-08-01T18:01:38.887Z","updated_at":"2025-10-19T12:22:23.546Z","avatar_url":"https://github.com/xwmx.png","language":"Shell","readme":"                      ___         ___         ___\n         _____       /  /\\       /  /\\       /__/|\n        /  /::\\     /  /::\\     /  /:/_     |  |:|\n       /  /:/\\:\\   /  /:/\\:\\   /  /:/ /\\    |  |:|\n      /  /:/~/::\\ /  /:/~/::\\ /  /:/ /::\\ __|  |:|\n     /__/:/ /:/\\:/__/:/ /:/\\:/__/:/ /:/\\:/__/\\_|:|____\n     \\  \\:\\/:/~/:\\  \\:\\/:/__\\\\  \\:\\/:/~/:\\  \\:\\/:::::/\n      \\  \\::/ /:/ \\  \\::/     \\  \\::/ /:/ \\  \\::/~~~~\n       \\  \\:\\/:/   \\  \\:\\      \\__\\/ /:/   \\  \\:\\\n        \\  \\::/     \\  \\:\\       /__/:/     \\  \\:\\\n         \\__\\/       \\__\\/       \\__\\/       \\__\\/\n\n# bask\n\nA framework for command-centric Bash scripts.\n\n## Features\n\nSome basic features available automatically:\n\n- Strict Mode,\n- Help template, printable with `-h` or `--help`,\n- `_debug` printing with `--debug` flag,\n- `_exit_1` and `_warn` functions with error message printing,\n- Option normalization (eg, `-ab -c` -\u003e `-a -b -c`) and option parsing,\n- Automatic arbitrary command loading,\n- A simple approach for specifying per-command help with `describe`,\n- Built-in commands for help, version, and command listing,\n- Conventions for distinguishing between functions and program commands,\n- Useful utility functions.\n\n## Installation\n\n### Homebrew\n\nTo install with [Homebrew](http://brew.sh/):\n\n```bash\nbrew tap xwmx/taps\nbrew install bask\n```\n\n### npm\n\nTo install with [npm](https://www.npmjs.com/package/bask.sh):\n\n```bash\nnpm install --global bask.sh\n```\n\n### bpkg\n\nTo install with [bpkg](http://www.bpkg.io/):\n\n```bash\nbpkg install xwmx/bask\n```\n\n### Manual\n\nTo install manually, simply add the `bask` script to your `$PATH`. If\nyou already have a `~/bin` directory, you can use the following command:\n\n```bash\ncurl -L https://raw.github.com/xwmx/bask/master/bask \\\n  -o ~/bin/bask \u0026\u0026 chmod +x ~/bin/bask\n```\n\n## Usage\n\n`bask` can be used primarily in two ways: with with scripts that source (or,\nin other words, inherit from) the `bask` program, or with Baskfiles defining\nfunctions for the current context.\n\n### Bask Scripts\n\nTo generate a new `bask` script, meaning a script that\ninherits the `bask` foundation, use add an argument to the `new`\ncommand specifying the script name:\n\n```bash\nbask new \u003cscript name\u003e\n```\n\nThis generates a script that sources the `bask` command. You can add\nbash functions in this script and they will be automatically set as\nsub-commands available as arguments to the program. Additionally, you\ncan easily document the programs using the built-in `describe` function.\nThe help / usage / description information set here is available in the\nvia the built-in `help` command.\n\n### Baskfiles\n\nA `Baskfile` is a file containing bash functions and optional\ndescriptions that can be run using the `bask` command directly, and can\nbe defined on a project-by-project basis. This can be useful for defining\ntask-centric commands within a particular scope where a full program\nwould be unnecessary.\n\nA `Baskfile` is similar to a [Makefile](https://en.wikipedia.org/wiki/Makefile)\nor a [Rakefile](https://en.wikipedia.org/wiki/Rake_(software)) and looks like\nthis:\n\n```bash\n# Baskfile\ndescribe \"hello\" \u003c\u003cHEREDOC\nUsage:\n  bask hello\n\nDescription:\n  Print a greeting.\nHEREDOC\nhello() {\n  echo \"Hello from bask!\"\n}\n```\n\nTo generate a new `Baskfile`, use `bask new` with no arguments:\n\n```bash\nbask new\n```\n\nWhen you run the `bask` program, it first looks in the\ncurrent directory for a `Baskfile` and sources it if one is present. If it\ndoesn't find a `Baskfile` in the current directory, it traverses the\nparent directories, sourcing the first `Baskfile` it encounters.\n\n### Commands\n\nCommands in `bask` are simply Bash functions with optional descriptions.\nDefined functions will be automatically loaded and displayed as part of\nthe usage information when the parent command is run. Command-specific\nusage information can be set with the `describe` function, and this usage\ninformation will be made automatically available to the parent program's\n`help` command.\n\nExample command group structure:\n\n```bash\ndescribe example \"\"  # Optional. A short description for the command.\nexample() { : }  # The command called by the user.\n```\n\nFor usage formatting conventions see:\n- http://docopt.org/\n- http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html\n\n#### Example Command Groups\n\n##### Micro Example\n\n```bash\ndescribe micro \"Usage: $_ME micro\"\nmicro() {\n  echo \"Hello, World!\"\n}\n```\n\n##### Simple Example\n\n```bash\ndescribe simple \u003c\u003cHEREDOC\nUsage:\n  $_ME simple [\u003cname\u003e]\n\nDescription:\n  Print the greeting, \"Hello, World!\"\nHEREDOC\nsimple() {\n  local _name=\"${1:-World}\"\n\n  printf \"Hello, %s!\\n\" \"${_name}\"\n}\n```\n\n##### Complex Example\n\n```bash\ndescribe complex \u003c\u003cHEREDOC\nUsage:\n  $_ME complex [\u003cname\u003e] [--farewell]\n\nOptions:\n  --farewell  Print \"Goodbye, World!\"\n\nDescription:\n  Print the greeting, \"Hello, World!\"\nHEREDOC\ncomplex() {\n  local _greeting=\"Hello\"\n  local _name=\"World\"\n\n  for __arg in \"${@:-}\"\n  do\n    case \"${__arg}\" in\n      --farewell)\n        _greeting=\"Goodbye\"\n        ;;\n      -*)\n        _exit_1 printf \"Unexpected option: %s\\n\" \"${__arg}\"\n        ;;\n      *)\n        if [[ \"${_name}\" == \"World\" ]] \u0026\u0026 [[ -n \"${__arg:-}\" ]]\n        then\n          _name=\"${__arg}\"\n        fi\n        ;;\n    esac\n  done\n\n  printf \"%s, %s!\\n\" \"${_greeting}\" \"${_name}\"\n}\n```\n\n## Optional Vim Configuration\n\nIn order to enable Baskfile syntax highlighting in Vim, add the\nfollowing line to your `.vimrc`.\n\n```VimL\nautocmd BufRead,BufNewFile Baskfile call SetFileTypeSH(\"bash\")\n```\n\n","funding_links":[],"categories":["Shell","bash"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxwmx%2Fbask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxwmx%2Fbask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxwmx%2Fbask/lists"}