Skip to content

Commit

Permalink
Merge pull request #5 from sqids/add-version-release
Browse files Browse the repository at this point in the history
Add version info & release
  • Loading branch information
king-p3nguin authored Jan 28, 2024
2 parents 8f1f6c5 + 2de2e3e commit 562b13a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# CHANGELOG

@todo
## [1.0.0] - 2024-01-28

### Added

- Initial implementation (#2)
- Add version info & release (#5)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [Sqids Bash](https://sqids.org/bash)

[![Github Actions](https://img.shields.io/github/actions/workflow/status/sqids/sqids-bash/tests.yml)](https://github.com/sqids/sqids-bash/actions)
[![Tests](https://github.com/sqids/sqids-bash/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/sqids/sqids-bash/actions/workflows/tests.yml)

[Sqids](https://sqids.org/bash) (*pronounced "squids"*) is a small library that lets you **generate unique IDs from numbers**. It's good for link shortening, fast & URL-safe ID generation and decoding back into numbers for quicker database lookups.

Expand Down
13 changes: 10 additions & 3 deletions src/sqids
Original file line number Diff line number Diff line change
Expand Up @@ -949,12 +949,13 @@ Description:
It's good for link shortening, fast & URL-safe ID generation and decoding back into numbers for quicker database lookups.
Usage:
$0 [-a alphabet] [-b block_list] [-h] [-l min_length] [-d ID] [-e numbers...]
$0 [-h] [-v] [-a alphabet] [-b block_list] [-l min_length] [-d ID] [-e numbers...]
Options:
-h Show this help message.
-v Show version.
-a Set custom alphabet. Default is "$DEFAULT_ALPHABET".
-b Set custom block list. See https://github.com/sqids/sqids-blocklist for default block list.
-h Show this help message.
-l Set minimum length of the ID. Default is 0.
-d Decode mode. Decodes the given ID into numbers. Cannot be used with -e.
-e Encode mode. Encodes the given numbers into an ID. Cannot be used with -d.
Expand All @@ -963,14 +964,19 @@ EOS
exit 0
}

version() {
echo "sqids-bash version 1.0.0"
exit 0
}

main() {
local mode
local min_length="$DEFAULT_MIN_LENGTH"
local alphabet="$DEFAULT_ALPHABET"
local block_list="${DEFAULT_BLOCKLIST[*]}"

local OPTIND=0
while getopts :a:b:l:edh OPT; do
while getopts :a:b:l:edhv OPT; do
case $OPT in
a)
alphabet="$OPTARG"
Expand All @@ -990,6 +996,7 @@ main() {
flag_d=true
;;
h) usage ;;
v) version ;;
?)
echo "ERROR: Invalid option -$OPTARG" >&2
exit 1
Expand Down
11 changes: 11 additions & 0 deletions tests/test_opt.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bats

@test "test_usage" {
run ./src/sqids -h
[ "$status" -eq 0 ]
}

@test "test_version" {
run ./src/sqids -v
[ "$status" -eq 0 ]
}

0 comments on commit 562b13a

Please sign in to comment.