Skip to content

Instantly share code, notes, and snippets.

View joshlawton's full-sized avatar
👨‍💻
Coding

Josh L joshlawton

👨‍💻
Coding
  • Atlanta, Georgia
View GitHub Profile
@mattmc3
mattmc3 / optparsing_demo.zsh
Last active November 16, 2024 20:46
Zsh option parsing example
# Manual opt parsing example
#
# Features:
# - supports short and long flags (ie: -v|--verbose)
# - supports short and long key/value options (ie: -f <file> | --filename <file>)
# - supports short and long key/value options with equals assignment (ie: -f=<file> | --filename=<file>)
# - does NOT support short option chaining (ie: -vh)
# - everything after -- is positional even if it looks like an option (ie: -f)
# - once we hit an arg that isn't an option flag, everything after that is considered positional
function optparsing_demo() {