- Notifications
You must be signed in to change notification settings - Fork22
bash script micro-framework - from small stand-alone script to complex projects with CI/CD and testing
License
NotificationsYou must be signed in to change notification settings
pforret/bashew
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
bash script / project creator
to create a new stand-aloneSCRIPT (just a xyz.sh script), with option parsing, color output (cf1.
)
bashew.sh script
to create a new standalone scriptPROJECT (in a folder, with README) (cf2.
)
bashew.sh project
to initialize a bashew-basedREPO with CI/CD you just cloned (cf3.
)
bashew init
- all code contained in 1 single file (no external dependencies)
- comes with
README.md
,CHANGELOG.md
, ... markdown files - edit only
Script:main()
function and subroutines in beginning of script, all template code is at the end of the script
- definition of flags/options/parameters in 1 place only
- automatic creation of usage text based on definition above
- short/long option parsing, based on definition above
- option
--lorem [value]
is available inside the script as$lorem
IO:
functions for IO, with intelligent color usage (not when output is piped) (e.g.IO.success
,IO.die
)Str:
functions for string manipulation (e.gStr:lower
,Str:digest
)Os:
functions for e.g. required program checking (e.g.Os:require convert imagemagick
)
- read multiple
.env
configuration files - predefined
--quiet
(no output) and--verbose
(more output) modes - folder for temporary files (with automatic cleanup)
- folder for log files (with automatic cleanup)
- correct determination of script installation folder (resolve symbolic links)
- easy CI/CD for Github (with shellcheck)
Program: bashew 1.18.2 by peter@forret.comUpdated: May 1 16:49:18 2022Description: package_descriptionUsage: bashew [-h] [-q] [-v] [-f] [-l <log_dir>] [-t <tmp_dir>] [-n <name>] <action>Flags, options and parameters: -h|--help : [flag] show usage [default: off] -q|--quiet : [flag] no output [default: off] -v|--verbose : [flag] output more [default: off] -f|--force : [flag] do not ask for confirmation (always yes) [default: off] -l|--log_dir <?> : [option] folder for debug files [default: /Users/pforret/log/bashew] -t|--tmp_dir <?> : [option] folder for temp files [default: /tmp/bashew] -n|--name <?> : [option] name of new script or project <action> : [parameter] action to perform: script/project/init/update
bashew.sh script# will interactively ask for author & script detailsbashew.sh -f script# will create new script with random namebashew.sh -f -n"../list.sh" script# will create new script ../list.sh
Example:
$bashew script⏳ 1. first we need the information of the authorAuthor full name (pforret) > Peter ForretAuthor email (peter@forret.com) >Author (github) username (pforret) >⏳ 2. now we need the path and name of this new script/repoScript name (./bespoke_bunny.sh) >⏳ 3. give some description of what the script should doScript description (This is my script bespoke_bunny) > process log files⏳ Creating script ./bespoke_bunny.sh ..../bespoke_bunny.sh$bashew -f script⏳ Creating script ./mediums_appease.sh ..../mediums_appease.sh
$bashew project# will interactively ask for author & script detailsor$bashew -f project# will create new project with random nameor$bashew -f -n"tango" project# will create new project in folder "tango"
Example:
$bashew -f project⏳ Creating project ./bounden_brawled ...CHANGELOG.md README.md VERSION.md LICENSE .gitignore .env.example bounden_brawled.sh bitbucket-pipelines .github✅ next step: 'cd ./bounden_brawled' and start scripting!
- ongithub.com/pforret/bashew, click on 'Use this template'
- then clone your new repo
$git clone https://github.com/<you>/<your repo>.git$cd<your repo>$./bashew.sh init# will ask for details and initialise/clean up the repo
and then, if you havesetver.sh:
$setver push# will commit and push new code$setver new patch# will set new version to 0.0.1$setverset 1.0.0# when your first working version is committed
$git clone --depth=1 https://github.com/pforret/bashew.git<newname>$cd<newname>$./bashew.sh init# will ask for details and iniialise/clean up the repo
- manually
$git clone https://github.com/pforret/bashew.git$ln -s bashew/bashew.sh /usr/local/bin
- or withbasher package manager
$basher install pforret/bashew
- bumpkeys: upgrade your SSH keys for better security
- crontask: call scripts or URLs from a crontab file, with optional logging and webhook upon success/failure
- jekyll_taxonomy: Generate tag and category pages for Jekyll static sites
- m1_homebrew: Install homebrew in native mode on Apple MacOS ARM
- mkdox: create and run Mkdocs Material websites using Docker image
- netcheck: test network: interfaces, gateway, router, internet
- note: Manage your notes, todo, ... with this nifty script
- pa: like "php artisan" but more intelligent (use optimal PHP version for the project
- progressbar: Easy, clever progress bar for (bash) scripts
- rexec: repeat a command and be alerted when the output changes
- saild: Start up your Laravel Sail dev setup in one go - Docker, Browser, Shell
- screenshots: Let GitHub automatically make 📸 screenshots of all your websites
- setver: Easy semver tool -- get/set git version (one-line superfast git commit)
- shaml: Read YAML files inside bash scripts
- shini: Read INI files inside bash scripts
- shlaunch: Launch desktop/GUI apps from CLI (e.g. Chrome, PHPStorm, Photoshop ...)
- shlorem: Lorem Ipsum generator for the command line
- shmixcloud: download Mixcloud shows and add album art to m4a files
- shoarma: Static Image Site Generator - make e.g. Jekyll posts from folder of images
- shtext: Text manipulation in bash, by always using the fastest method
- shwiki: Wikipedia CLI in bash
- shwordle: Wordle-clone with variable # of letters and multiple languages
- splashmark: download/create (unsplash/pixabay/replicate) pics and resize/add effects/add attribution/watermark
- teams-cli: Send messages to MS Teams channels from CLI
- xkcd: View a XKCD comic in your console/TTY
- bash_unit: bash unit testing enterprise edition framework (used for CI/CD)
- shellcheck: a static analysis tool for shell scripts (used for CI/CD)
- bash-boilerplate (2012) on which I based mybash-boilerplate (2020) which eventually became thisbashew
- Bash documentation fromGoogle,BashPitfalls,Microsoft
- derived from 'bash new'
- rhymes with cashew
About
bash script micro-framework - from small stand-alone script to complex projects with CI/CD and testing