Skip to content

Commit

Permalink
✨ (glit): Add versioning (#15)
Browse files Browse the repository at this point in the history
* ✨ (glit): Add display_version fn

* ✨ (glit): Add -v/--version option

* 📝 (README): Update options section

* ♻️ (glit): Add global for RELEASE_DATE
  • Loading branch information
justJackjon authored Oct 10, 2023
1 parent 2c970ea commit 31cc151
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,14 @@ If your current working directory is within an initialised git repository, there

### Options

- `-d, --dir`: Specify the path to the mounted volume directory. Default is `/SharedRepos`. The path is relative to the root of the mounted volume.
- `-e, --exclude`: Comma-separated list of paths to exclude from syncing. Paths should be relative to the repository root. Default exclusions include: `node_modules/`, `.git/`, `bin/`, `obj/`.
- `-f, --force`: Initiates the sync immediately, foregoing the formatted change summary. This option is a faster alternative to `-y`/`--yes`, which requires a dry run to produce the change summary.
- `-h, --help`: Display the help message and exit.
- `-t, --type`: Specify the type of mounted volume: 'networked' or 'removable' (e.g., a USB stick). Default is 'networked'.
- `-V, --volume`: Specify the name of the mounted volume. Default is '`z`'. Ensure the volume is mounted and writable at the following locations: For macOS, under `/Volumes`. For Linux, use `/mnt` for networked volumes and `/media` for removable volumes.
- `-y, --yes`: This option bypasses user confirmation by auto-responding 'yes' to the sync confirmation prompt. However, it still produces the formatted change summary for review after the sync. If `-f`/`--force` is also specified, this option is disregarded.
- **`-d, --dir`**: Specify the path to the mounted volume directory. Default is `/SharedRepos`. The path is relative to the root of the mounted volume.
- **`-e, --exclude`**: Comma-separated list of paths to exclude from syncing. Paths should be relative to the repository root. Default exclusions include: `node_modules/`, `.git/`, `bin/`, `obj/`.
- **`-f, --force`**: Initiates the sync immediately, foregoing the formatted change summary. This option is a faster alternative to `-y`/`--yes`, which requires a dry run to produce the change summary.
- **`-h, --help`**: Display the help message and exit.
- **`-t, --type`**: Specify the type of mounted volume: 'networked' or 'removable' (e.g., a USB stick). Default is 'networked'.
- **`-v, --version`**: Display the current version of `glit` and exit.
- **`-V, --volume`**: Specify the name of the mounted volume. Default is '`z`'. Ensure the volume is mounted and writable at the following locations: For macOS, under `/Volumes`. For Linux, use `/mnt` for networked volumes and `/media` for removable volumes.
- **`-y, --yes`**: This option bypasses user confirmation by auto-responding 'yes' to the sync confirmation prompt. However, it still produces the formatted change summary for review after the sync. If `-f`/`--force` is also specified, this option is disregarded.

## Examples

Expand Down
22 changes: 21 additions & 1 deletion main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ source "$DIR/modules/utils.sh"
source "$DIR/modules/sync_fns.sh"
source "$DIR/modules/loading_spinner.sh"

# --- Usage Fn ---
# --- Display Info Fns ---

display_help() {
echo ""
Expand All @@ -65,6 +65,8 @@ display_help() {
echo " -t, --type Specify the type of mounted volume: 'networked' or 'removable'."
echo " Default is 'networked'."
echo ""
echo " -v, --version Display version information and exit."
echo ""
echo " -V, --volume Specify the name of the mounted volume. Default is '$DEFAULT_VOLUME_NAME'."
echo " Ensure the volume is mounted and writable at the following"
echo " locations: For macOS, under \`/Volumes\`. For Linux, use \`/mnt\`"
Expand All @@ -81,6 +83,24 @@ display_help() {
exit 0
}

display_version() {
echo ""
echo -e "\e[1m\`glit\` $VERSION\e[0m"
echo ""
echo "Release Date: $RELEASE_DATE"
echo ""
echo "License: MIT"
echo -e "Website: \e]8;;https://github.com/justJackjon/glit\ahttps://github.com/justJackjon/glit\e]8;;\a"
echo -e "Contact: \e]8;;https://github.com/justJackjon/glit/issues\ahttps://github.com/justJackjon/glit/issues\e]8;;\a"
echo ""
echo "About:"
echo "\`glit\` is a user-friendly wrapper around \`rsync\`, designed to assist in synchronising"
echo "git repositories with mounted volumes such as networked drives or removable media."
echo ""

exit 0
}

# --- Main Logic ---

parse_config
Expand Down
5 changes: 5 additions & 0 deletions modules/arg_parsing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ parse_options() {

shift $TWO_VALUES_CONSUMED
;;
-v|--version)
display_version

# NOTE: display_version will exit, so we don't need to do anything else here.
;;
-V|--volume)
check_opt_missing_value "$current_value" "$next_value"

Expand Down
2 changes: 2 additions & 0 deletions modules/variables.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
VERSION="v0.0.1-alpha"
RELEASE_DATE="October 10, 2023"
FORCE_ACTION=0
AUTO_CONFIRM=0
DEFAULT_VOLUME_NAME="z"
Expand Down

0 comments on commit 31cc151

Please sign in to comment.