Sh:erpa brings Cargo, OhMy' and WebDev worflow to Bash scripting, using the Terminal as a browser!
Because WebDevs should be able to do more than npm run dev
in a terminal, and Bash lovers don't have to be reduced to automations
writers, obviously because I like both sides.
Docs: sherpa-cli.netlify.app - Discord: Community Discord Server
JavaScript, PHP, Rust and other languages can indeed generate CLI tools with shell-like approaches, nevertheless Bash actually IS a shell, handling everything as expected. What the other languages often have is better tooling around, making for a nicer developer experience.
Sh:erpa's goal is to be that tool, simplifying the creation of scripts & libraries and helping non-devs actually installing and using them. It's just a beginning, the imagination is the limit.
Note: First time i'm talking about, so really need feedback <3
Quick install
Be sure to have Bash, curl, gawk instaled, then run the installer:
bash -c "$(curl -sLo- https://sherpa-cli.netlify.app/install.sh)"
It will do the following:
- A. Install the CLI tools if not already installed.
- B. Clone the Sh:erpa repo as ~/.sherpa
- C. Add to the $PATH ~/.sherpa/bin
- D. Initiate the SherpaCustomDir as ~/sherpa
Use a Linux Distribution, still a Linux Distro but from WSL2 or MacOS. For good measure once installed, you can run sherpa self-update
to re-generate the executable.
See the docs for more details.
The BashBox (think Crate) Anatomy
When running: sherpa new myScript
the following is generated:
# /home/user/sherpa/boxes/myScript
.
├── data
│ └── file.yaml
├── docs
│ └── myScript.md
├── README.md
├── Sherpa.yaml
├── src
│ ├── bin.sh
│ ├── _globals.sh
│ ├── _header.sh
│ ├── _lib.sh
│ ├── _options.sh
│ └── __paths.txt
├── target
│ └── local
│ └── myScript
└── tests
└── example_test.sh
Looks familiar? A simple src/bin.sh
file could look like that:
use "std/fmt"
main() {
# Data
dude="$(dataGet "hiker" "name")"
# Template
h1 "Greetings adventurer :)"
hr "+" "-" # ------+------
br
p "Welcome ${txtBlue} ${dude} ${x}!"
}
# Main Route. Script called with no arguments
[[ "$#" == 0 ]] && main; exit 0
Sh:erpa will merge the partials plus those sourced with use "dir/file"
, generate docs, remove comments and blanks, then build the script and make it available for direct invocations and eventually re-build on files save.
The tool can be picked-up by WebDevs discovering Bash or experienced shell scripters taking advantage of the build, watch and organisation or distribution, while writing things their own way.
The docs website will get soon a Ressources section, with cheat-sheets, examples and other helpful things to kick off projects.
Local Libraries
To create your own local library, use something as sherpa new bob lib
. This would scafold a library version of a BashBox in /home/user/sherpa/lib
with that structure:
# home/user/sherpa/lib/bob
.
├── data
│ └── example.yaml
├── lib.sh
├── README.md
├── Sherpa.yaml
└── tests
└── example_test.sh
Any .sh file in bob/
can be imported in any BashBox with use "bob/fileName"
.
Install community-made packages
So far, we can install remote BashBoxes or Libs from Git repositories with:
- BashBox:
sherpa install -n "<someName>" -u "<repoUrl>"
- BashLib:
sherpa install -n "<someName>" -u "<repoUrl>" -t "lib"
More details in the Documentation, and some available repos to play with soon listed, so stay tuned or comme say hi.
Features
Check the Sh:erpa Website or come talk in the Discord, but some included features are:
- Modular + build-step workflow
- Pug-like semantic formating
- Non verbose styling options
- CRUD operations on .yaml files
- Fetch API data and use JSON in Bash
- CDN-like imports for remote Libs
- Integrated UnitTests suite
- Docs generation from comments
- Install/Up/Remove remote BashBox or Lib
- Source local libs with
use "dir/file"
- Helpers for env variables or package data
- Helper for
Are you sure? (y/n)
confirm - ...to name some of them.
Commands
🔗 | Command | Description |
---|---|---|
🔗 | sherpa |
Dashboard. List of local/remote scripts & libs |
🔗 | sherpa new <myPackage> |
Create a BashBox directory and script |
🔗 | sherpa new <myPackage> lib |
Create a BashLib directory and library file |
🔗 | sherpa rmBox <boxName> |
Delete a local BashBox and clean registers |
🔗 | sherpa rmLib <libName> |
Delete a local BashLib and clean registers |
🔗 | sherpa install ... |
See docs. Installing a remote BashBox or Lib |
🔗 | sherpa uninstall ... |
See docs. Uninstalling a remote BashBox or Lib |
🔗 | sherpa update <boxName> |
Update an installed BashBox |
🔗 | sherpa upLib <libName> |
Update an installed BashLib |
🔗 | sherpa self-update |
Update sh:erpa itself to the lastes version |
🔗 | sherpa init |
Just like 'new' but from an existing directory |
🔗 | sherpa b, build |
Build the myScript.sh and optimise things |
🔗 | sherpa w, watch |
Watching for changes and build on file-save |
🔗 | sherpa r, run |
Build the script and execute it |
🔗 | sherpa t, test |
Run tests from the tests/ dir, with BashUnit |
🔗 | sherpa self-test |
Run Sh:erpa's tests from ~/.sherpa/tests |
🔗 | sherpa d, doc |
Build .md docs from files in src/, with shDoc |
🔗 | sherpa compile |
Compile myScript.sh to a binary, using SHC |
🔗 | sherpa e, edit bin |
Open the src/bin.sh file |
🔗 | sherpa e, edit opt |
Open the src/_options.sh file |
🔗 | sherpa e, edit yaml |
Open the Sherpa.yaml file |
🔗 | sherpa e, edit basecamp |
Open the ~/.sherpa/basecamp.sh file |
🔗 | sherpa aliases |
List/edit the aliases created with Aliasman |
🔗 | sherpa links |
List the Symlinks in ~/.sherpa/bin. (Old command) |
Since relative paths are used, some commands need to be used from a package root directoy: build, watch, run, test, doc, compile, edit.
Aliases
Upon first install, some aliases are created via Aliasman. They can be visualised and eventually changed via sherpa aliases
command, wich is just a shortcut for aliasman -e
and opens the file storing them (with the default editor, like vim).
alias | replace | effect |
---|---|---|
s | sherpa | Shorter s commands |
sdd | cd $HOME/.sherpa | Jump into the Sherpa Dot Dir |
scd | cd $HOME/sherpa | Jump into the Sherpa Custom Dir |
boxes | cd $HOME/sherpa/boxes | Jump into the local Boxes Dir |
After having created a BashBox with s new <myScript>
, you can:
- Jump into the directory:
boxes && cd myScript
- Open the main file:
s e bin
- or any other command you need from the Root.
Credits
Special shoutout to every person who has contributed code and genius ideas to the computing world since the first second of the Unix timestamp, making todays coding possible. Plus...
- Rust Cargo: For the perfect package management workflow.
- OhMyBash/ZSH: For the core/custom architecture inspiration.
- Webinstall.dev: For making the install possible via the awesome webi tool.
- Integrated projects: BashUnit, shdoc, bashdoc, SHC, Pathman, Aliasman, WatchExec, ...
- The non-dev people around me, enduring my talks about CLI, WebDev & how interesting Sh:erpa can be. They all hope that the Discord will be active enough so I could spare them.
That's all for now, more to come, it's a young project so far from perfect but working on...
—AndiKod—
Header image credit:
https://unsplash.com/photos/gray-rock-under-gray-fog-PLzgu9O7xag
Top comments (0)