Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/idelstak/number-range
Processes number ranges from command-line arguments or standard input, with options for sorting, handling negative numbers, and ensuring uniqueness.
https://github.com/idelstak/number-range
Last synced: about 1 month ago
JSON representation
Processes number ranges from command-line arguments or standard input, with options for sorting, handling negative numbers, and ensuring uniqueness.
- Host: GitHub
- URL: https://github.com/idelstak/number-range
- Owner: IdelsTak
- License: mit
- Created: 2024-07-31T04:52:21.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-07-31T11:08:38.000Z (5 months ago)
- Last Synced: 2024-08-01T06:49:32.784Z (5 months ago)
- Language: Java
- Homepage:
- Size: 19.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NumberRange Utility
Processes number ranges from command-line arguments or standard input, with options for sorting, handling negative numbers, and ensuring uniqueness.
## Usage
```sh
java NumberRange.java [options] [NUM-RNG]
```### Options
- `-h`: Print this help message.
- `-s` : Sort the numbers within a line before printing.
- Note: Sort only occurs within a line (from stdin) or within a single argument (from CLI), not globally.
- `-n`: Input has negative numbers (input must use `:` instead of `-` for range separator).- `-u`: Print only unique numbers (implies sorting).
### NUM-RNG
Number Range in human-readable format. Pass `-` for stdin. The number range can be a comma-separated list of single range numbers, which can be a single number, `start:end`, or `start:step:end`. For non-negative numbers, `-` can be used instead of `:` for range separator. The range separator will be auto-detected unless the `-n` (negative) flag is on.
## Examples
```sh
java NumberRange.java 1-4 # 1, 2, 3, 4
java NumberRange.java 1:4 # 1, 2, 3, 4
java NumberRange.java -1:2 # -1, 0, 1, 2
java NumberRange.java 5:1:2 # 5, 4, 3, 2
java NumberRange.java 30:32,1:4,31 # 30, 31, 32, 1, 2, 3, 4, 31
java NumberRange.java 30:32,1:4 -s # 1, 2, 3, 4, 30, 31, 31, 32
java NumberRange.java 30:32,1:4 -u # 1, 2, 3, 4, 30, 31, 32
```## Running the utility
```sh
java NumberRange.java [options] [NUM-RNG]
```