Bash Cli Library

A framework for building @hard_link(https://www.gnu.org/software/bash/, Bash libraries). Originally developed in and currently used by @easy_link(tlf, git-bent, Git Bent), a wonderful wrapper for git

Notice

This library is ready to use, but the documentation has issues due to an old development dependecy.

Why Use this over others?

  • Easy to get started
  • Fairly minimal
  • Nice help menus for your library
  • Convenience Functions - see @see_file(doc/Functions.md)
  • You like how @easy_link(tlf, git-bent, Git Bent) works and want a library like it

Example

This is the actual code executed to setup new bash libraries with ./bash-cli setup. step is one of our built-in functions.

@ast(function, core_setup, definition)

Set up a new library

  1. cd to the root of the new library.
  2. git clone @git(https_url) vendor/bash-cli
  3. ./vendor/bash-cli/bash-cli setup new project
  4. Follow the prompts. Then source ~/.bashrc or re-launch your terminal.
  5. Look at the sample code in your new library
  6. Run yourlib help or ./bin/yourlib help
  7. Write a couple functions & run them to get a sense of how things work.

Development tools (optional, recommended)

We use @easy_link(tlf, code-scrawl, Code Scrawl), a Php package, to generate help menus and documentation. You caaaaan write help menus manually.

To use the tools, we require Php & Composer (Php's popular package manager). Php is only required for development. Your bash library's users will not need Php.

  1. @easy_link(tlf, howto/install-php, Install Php)
  2. @easy_link(tlf, howto/install-composer, Install Composer)
  3. cd vendor/bash-cli; composer install; - installs Code Scrawl and its dependencies.
  4. cd ../.. (back to your project root) then vendor/bash-cli/bash-cli scrawl
    • The help menus have been re-generated, as well as documentation
  5. You may want to edit .config/scrawl.json inside your project to your liking.
  6. See @easy_link(tlf, php/code-scrawl, Code Scrawl) for more info on documentation generation.

Connect

  • @easy_link(twitter, TaelufDev)
  • @hard_link(https://taeluf.com, Taeluf.com)

Alternatives / Competition

  • @hard_link(https://github.com/Bash-it/bash-it, Bash-it): "Bash-it provides a solid framework for using, developing and maintaining shell scripts and custom commands for your daily work"
  • @hard_link(https://github.com/niieani/bash-oo-framework, Bash OO Framework): "Bash Infinity transforms the often obfuscated "bash syntax" to a cleaner, more modern syntax"
  • @hard_link(https://github.com/wschlich/bashinator, Bashinator): "Bashinator is a framework for bash shell scripts."
  • @hard_link(https://dberkholz.com/2011/04/07/bash-shell-scripting-libraries/, (old) List of Bash Scripting Libraries) or @hard_link(https://web.archive.org/web/*/https://dberkholz.com/2011/04/07/bash-shell-scripting-libraries/, WebArchive Link)

Notes

  • I have no idea if this works on Windows with WSL or git bash. It probably works on Mac. I use Linux. You can submit PRs for compatibility with different systems

Development

If you want to contribute, you do not need php. I will gladly run the documentation generation myself & eventually will do this with CICD.

This uses PHP packages to generate documentation & help menus. This requires composer (to install dependencies), php language, and I'm pretty sure composer requires git, but you probably have that already

To setup the dev environment, make a fork, then:

git clone git@gitlab.com:your_vendor_name/bash/git-bent.git git-bent # Put in the correct url for your fork.
cd git-bent/.config
composer install
cd ..

Then to generate documentation & help menus:

vendor/taeluf/code-scrawl/cli/scrawl

& just answer 'y'