bargs

A framework for creating a Bash CLI application.

MIT License

Stars
156
bargs - v1.1.5 Latest Release

Published by unfor19 6 months ago

What's Changed

New Contributors

Full Changelog: https://github.com/unfor19/bargs/compare/v.1.1.4...v1.1.5

bargs - v.1.1.4

Published by unfor19 about 3 years ago

  • Using recommended bash shebang
  • Updated Dockerfile.example alpine version from 3.12 to 3.14
  • Updated docs for easy copy-paste snippets of code
bargs - v1.1.3

Published by unfor19 almost 4 years ago

  • Fixed breaking hidden prompts with CTRL+C

  • Prettier example.sh, making it more readable

  • Fixed getting the proper env var if already exists, for example, the following caused age to be empty

    GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1 # agent contains "age"
    ...
    age=33
    
bargs - v1.1.2

Published by unfor19 about 4 years ago

  • Support CTRL+C to terminate
bargs - v1.1.1

Published by unfor19 about 4 years ago

  • [ADDED] Flexible Assignment enables passing arguments with the equal sign or a whitespace
example.sh --name "Willy Wonka"
example.sh --name="Willy Wonka"
bargs - v1.1.0

Published by unfor19 about 4 years ago

  • [ADDED] Reference to a specific bargs_vars file by setting the environment variable BARGS_VARS_PATH

In your application example.sh

export BARGS_VARS_PATH="$bargs_vars_path"
source "${PWD}"/"$(dirname ${BASH_SOURCE[0]})"/bargs.sh "$@"

This feature enables having a single bargs.sh file, with multiple bargs_vars in the same repository. It's now possible to embed bargs in multiple Bash scripts that reside in the same repository.

Version bumped from v1.0.14 to v1.1.0 🎉

bargs - v1.0.14

Published by unfor19 about 4 years ago

  • [BUGFIX] Environment variables are used only if not empty, otherwise, fallback to default
bargs - v1.0.13

Published by unfor19 about 4 years ago

  • [ADDED] Fallback to environment variables with allow_env_var=true
bargs - v1.0.12

Published by unfor19 about 4 years ago

  • [ADDED] Shellcheck on creating pull-requests
  • [MODIFIED] Reorganized code to run in functions, this helps to avoid polluting the global scope
bargs - v1.0.11

Published by unfor19 about 4 years ago

  • [MODIFIED] Minor cleanup thanks to @toazd
bargs - v1.0.10

Published by unfor19 about 4 years ago

  • [ADDED] Definition flag=true, when using it, the value of the argument will be set to true
bargs - v1.0.9

Published by unfor19 about 4 years ago

  • [ADDED] Providing empty values is now possible! allow_empty=true
  • [ADDED] Prompting for arguments is available! prompt=true, hidden=true and confirmation=true
bargs - v1.0.8

Published by unfor19 about 4 years ago

Minor updates in pipeline

bargs - v1.0.7

Published by unfor19 about 4 years ago

  • Variables names are also exported as UPPERCASED, for example person_name is also available as PERSON_NAME
  • Added update_testresults.sh script which updates the README.md file according to the results of tests.sh
bargs - Update docs

Published by unfor19 about 4 years ago

  • Whitespaces are supported for the default definitions in bargs_vargs; updated the docs and examples accordingly
bargs - Run from anywhere

Published by unfor19 over 4 years ago

  • [MODIFIED] Previously, it was possible to use bargs only if you run your application from the same PWD. Now it's possible to use bargs, and execute your application from any directory
  • [MODIFIED] Wording in README.md and updated examples according to test output
  • [ADDED] Test for checking that bargs_vars is in the same folder as bargs.sh
bargs - Minor fixes

Published by unfor19 over 4 years ago

  • [ADDED] tests.sh - Function log_msg to avoid hardcoding the message
  • [ADDED] tests.sh - Test for help message flag -h
  • [MODIFIED] bargs.sh - Removed the exit command from usage function; makes it possible to be used in the -h case
  • [FIXED] bargs.sh - Unknown Argument printed [ERROR] [ERROR]instead of printing[ERROR]` once
bargs - options definition

Published by unfor19 over 4 years ago

You can now define options, the values of options must be separated with a whitespace

bargs_vars snippet

---
name=gender
short=g
description='male or female?'
options=male female
---
bargs - Avoiding `eval`

Published by unfor19 over 4 years ago

Again, thanks to the community feedback, removed the use of eval when it's not absolutely necessary.

bargs - Trapping errors

Published by unfor19 over 4 years ago

As part of the community feedback, you can now use quotes, " and ' in the bargs_vars file.

Even though it's not really necessary, it can lead to weird behavior to add quotes prior to this release.