Skip to content

Releases: zpiatt/gen

v2.0.4

11 Aug 20:24
Compare
Choose a tag to compare

Version 2 is here! Gen has come a long way from a simple function in my bashrc. I've probably learned more Bash than anyone needs to know in making this, and it's been a lot of fun. Thank you to everyone who helped get me this far!

This release contains a major functionality change, and several small bug fixes:

Bug Fixes/Improvements:

  1. Realigned templates with original design intent. Only shell script support is hard-coded into gen.
    • Custom templates continue to be 100% optional, however, gen installs several examples by default.
    • My goal is to make the main script as simple as possible with the intent for streamlined scripting; not a replacement for robust boilerplate solutions.
  2. Complete overhaul of error codes and exit statuses.
    • Gen will now exit on errors with statuses that reflect the nature of the error. Please check out the man page for more details.
  3. Man page is now complete.
    • The man includes details on exit statuses, a thorough explanation on how gen selects an editor, the thought process for changing file permissions, and descriptions for all arguments.
  4. Removed all HereDocs.
    • This is purely a style choice, however, HereDocs require actual tab characters to maintain readability. In practice, HereDocs (IMHO) become unreadable easily, so I did away with them entirely.
    • I made several other small changes in the name of readability.
  5. Complete rework of the create_file function to handle all error cases ( hopefully ).
  6. Complete rework of file permission assignments.
    • gen now automatically ensures at least read/write permissions are given to the user. In practice, this should catch any umask errors, or read-only filesystems.
    • Gen relies on the robust error handling of chmod and allows error messages from chmod to be printed.
  7. Deprecated -x option. -c now handles all possible custom file permissions. ( Must use octal mode bits [ i.e. 754, etc. ] ).
    • I also added input validation to -c that confirm a user enter 3 digits from 0-7. I may revisit this and attempt to include symbolic mode bits ( u+rw ) as well.

Moving forward:

  1. I'm working on adding workflows for automated testing. I have almost no knowledge of how this works, so this is mostly for me to learn. My goal would be more reliable commits.
  2. No features will be pushed/pulled that cannot pass shellcheck AND set -o nounset.

v1.7.0-stable

04 Jul 14:14
Compare
Choose a tag to compare

This release contains a major bug fix and several small bug fixes:

Bug Fixes/Improvements:

  1. Added input validation for providing a directory path to gen.
    • Previously, gen would launch an editor into the directory ( same as vim <directory> ); now it provides an error message similar to rm <directory> ( i.e without -rf ) and exits with error code 1.
    • Crucially, prior to this change, gen was attempting to make other changes to the directory. This could have unintended consequences especially in the case of selecting custom modes ( i.e. gen -c 777 <directory> )
  2. Added additional input validation to the create_file function; allowing for users to answer y or yes (regardless of capitalization) when overwriting an existing file.
  3. Fixed bug with selection of custom mode. The -c option now sets the variable $cust_mode and the mode is set accordingly: chmod "${cust_mode:-${mode}}" "$filename".
    • Previously, if a file extension was recognized in the get_ext function, and it called for the mode to be set, it would overwrite $mode.
  4. Additionally, I found a redirection error in the which_ed function where stdout/stderr were being redirected, preventing $editor being set by the stdout of the command: editor="$(which "$ed" 2> /dev/null)"
    • I also changed the verification of editors to the builtin command -v. In practice, this should be both faster and more portable.
    • In the get_args function, when an editor is being selected manually ( gen -e nano ), I created an error message similar to the error output of type.

Moving forward:

  1. I'm working on re-adding the create_multi function (or at least that feature). I removed it with the last release because I was unhappy with it's performance. My goal is to allow for creating multi files as you would with touch ( i.e. gen test{00..99}.sh ) with minimum impacts to performance.
  2. No features will be pushed/pulled that cannot pass shellcheck AND set -o nounset.

v1.6.4

08 Jun 03:34
Compare
Choose a tag to compare

This release contains several small bug fixes and two new features:

  1. Added -f option to overwrite existing file without prompting. This function is similar to rm -f
  2. Added manual page. Man page installs automatically with Makefile installation. Ideally this file would be compressed, but I left it uncompressed so it can be reviewed prior to installation/download.
  3. Removed create_multi function. In practice, this feature had limited applicability and unnecessarily complicated the program. If I find someone was relying on this feature I could consider rethinking how to implement it.

Bug Fixes/Improvements:

  1. Removed localization settings. Setting LC_ALL=C and LANG=C did yield an improvement in the primary script's performance. However, an unintended consequence was this overrode the user's localization settings when the editor launched.
  2. Removed error redirection to /dev/null when using touch to create file. Full error messages from touch are now displayed to account for all possible errors (permissions, file system fault, non-existent path, etc.).
  3. The create_file function now prompts users to overwrite a file if it exists. Overwrite message appears similar to common commands (i.e. rm -i or mv -i) .

Moving forward:

  1. No features will be pushed/pulled that cannot pass shellcheck AND set -o nounset.

v1.6.0-stable

26 Dec 17:02
Compare
Choose a tag to compare

My first stable version! This release contains several small bug fixes and one new feature:

  1. Added -c option for customization of file permissions. The default functionality of gen adds user-owner execute permissions for formats that are typically executable. Previously, the -x option was added to assign user-owner execute permissions for any format (this was done with custom templates in mind). Now -c allows for more granularity of file permissions. NOTE: both symbolic notation ( gen -c ug+x test.sh ) and octal notation ( gen -c 775 test.sh ) are valid.
  2. Gen now checks environmental variables $VISUAL and $EDITOR. This is similar to common command line tools ( git, visudo, less, etc ). To ensure an editor launches, gen also tests a user's $PATH for: nano, vi, and ed. I added input validation when selecting an editor ( gen -e emacs test.sh) using which. I also clarified that gen effects only local variables by setting $editor instead of $EDITOR.
  3. Removed which_template function. After realizing I tested [[ -z $template ]] in check_ext only to again test [[ -n $template ]] in which_template I removed the latter.
  4. Set LC_ALL=C and LANG=C. In my testing, forcing ASCII in lieu of Unicode improved overall performance by ~8%. This improvement is perceivable when generating multiple files at once.

Moving forward:

  1. This is my first release labeled stable as I am now confident gen is consistent across common version of Linux, UNIX, and BSD. However, I will continue testing focused on improving portability and overall speed.
  2. No features will be pushed/pulled that cannot pass shellcheck AND set -o nounset.

v1.5.6

23 Dec 04:40
Compare
Choose a tag to compare

This release contains several small bug fixes:

  1. Updated which_ed function to use which to search $PATH for installed editors. In practice, this should be both faster, and more portable.
  2. Moved test for appropriate number of arguments to check_args function. This tests for a user inputting a valid option without a valid filename argument.
  3. Corrected the regular expression used to validate user input for create_multi allowing for any positive integer to be input.
  4. Standardized error reporting throughout. I'm now fairly confident error reporting, if not perfectly aligned with "best practices", is similar to common CLI tools.
  5. Removed instance of potentially unset variable from check_ext.
  6. Clarified where parameter expansions were being used by removing superfluous curly braces.
    • This is purely a style preference, and I may still use curly braces as delimiters where I think it improves readability.

Moving forward:

  1. Continues testing focused on improving portability.
  2. I'm working on an option to make the file permissions customizable (i.e. gen -c 775 test.sh or gen -c ug+x test.sh)
  3. No features will be pushed/pulled that cannot pass shellcheck AND set -o nounset.

v1.5.1

17 Dec 13:45
Compare
Choose a tag to compare

This release contains several small bug fixes and one major feature update as below:

  1. Gen now uses shift within the getopts built-in function to assign filename within get_args using the positional argument $1. In my testing, I found errors assigning filename dynamically to the last argument with a variety of methods. One portable solution I found was: for i in $@; do :; done, however, I believe the shift solution is more readable.
  2. Added -m to generate multiple files at once. This feature mimics the behavior of brace expansions as in: touch test{1..3}.sh to create test1.sh, test2.sh, etc. I'm not completely happy with this as my goal was to allow brace expansions inside gen ( i.e. gen test{1..3}.sh ) so look for this feature to change/improve in the future.
  3. Added *sh to check_ext to catch several shell scripting languages (ksh, csh, zsh, etc).

Moving forward:

  1. I've added all the major features I had in mind when I started this project, so I will mostly be focused on improving portability.
    • I will be still be welcoming new features/improvements ideas, so keep them coming!
  2. No features will be pushed/pulled that cannot pass shellcheck AND set -o nounset.

v1.4.0

03 Dec 19:32
b56a6b1
Compare
Choose a tag to compare

The initial releases have been focused primarily on "proof of concept." However, this released was focused entirely on bug fixes. I tried to capture the many bug fixes below, but some may have been missed.

  1. Generate now passes set -o nounset testing in a variety of shell environments.
    • unset/unbound variables should be eliminated.
  2. Added get_ext function to further validate file extension.
    • function prevents an ext == filename in the case of zero/multiple . in filename.
  3. Changed variable capitalization to differentiate between environmental variables.
  4. Added check preventing zero arguments passed to gen.
  5. Clarified instances of ! -n or ! -z with -z or -n respectively.
  6. Reordered main function for improved logic and readability.

Big thanks to everyone who has helped!

Moving forward:

  1. Continued work on bug testing/compatibility testing.
  2. Reviewing error handling.
    • Current error reporting similar to common CLI tools, however;
    • The goal is to find the balance of terse specificity.
    • Continue to identify unknown/unreported errors.
  3. No features will be pushed/pulled that cannot pass shellcheck AND set -o nounset.

v1.3.0

29 Nov 16:34
1d85770
Compare
Choose a tag to compare

Several bug fixes with this release, clarified variable and function names throughout, and finished integration of custom templates.

  • Added support for .jsx files
  • Fixed exit codes defaulting to 0
  • Added explicit error messages for failure to touch and failure to launch editor
  • Updated Makefile to include installation of ${HOME}/.gen/templates directory
    • "$TEMPLATE_FILE" inside gen now points here
    • This update allows gen to be updated without conflicts/overwriting custom templates

Thank you to @Ekatwikz and @greek-2me and the homies at [r/commandline] for getting me this far!

v1.2.1-beta

28 Nov 01:29
d5e4dd1
Compare
Choose a tag to compare

Initial Release

Let's get this out of the right at the start. I'm a Linux Sysadmin...not a software engineer. This project is a "learn-by-doing" experience. It started as something I was doing at work for a super specific use-case but evolved into something that might be helpful to others, so here we are.

Huge thanks to @tmiland, @greek-2me, and @fearlessgeekmedia for helping me get this far.

I will be more detail oriented for change logs going forward, this time I just want to get the ball rolling!