Skip to content

Commit

Permalink
1.1.1
Browse files Browse the repository at this point in the history
- Fix CLI not parsing pre and rc versions
  • Loading branch information
Nixinova committed Feb 12, 2021
1 parent 2dd3b1c commit 25c4e21
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.1.1
*2021-02-13*
- Fixed command-line usage not parsing pre-release and release candidate versions.

## 1.1.0
*2021-02-13*
- Added argument `type` to Node usage; valid values are `'data'` and `'resource'` for retrieving the respective pack format for certain versions.
Expand Down
17 changes: 9 additions & 8 deletions cli.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
#!/usr/bin/env node
const VERSION = '1.1.0'
const VERSION = '1.1.1'

const getPackFormat = require('./index.js')

const arg = n => process.argv[n + 1]

if (arg(1) && !arg(1).includes('h'))
if (arg(1).includes('v'))
if (/v/.test(arg(1)))
console.log(`The current version of pack-format is ${VERSION}`)
else if (arg(1).includes('d'))
else if (/^-*d/.test(arg(1)))
console.log(`Data pack format of ${arg(2)} is ${getPackFormat(arg(2), 'data')}`)
else if (arg(1).includes('r'))
else if (/^-*r/.test(arg(1)))
console.log(`Resource pack format of ${arg(2)} is ${getPackFormat(arg(2), 'resource')}`)
else
console.log(`Pack format of ${arg(1)} is ${getPackFormat(arg(1))}`)
else {
const indent = n => ' '.repeat(n * 4)
const log = (arg, desc) => {
console.log(`\n\tpack-format ${arg}`)
for (text of desc) console.log('\t ' + text)
console.log(`\n${indent(2)}pack-format ${arg}`)
for (text of desc) console.log(indent(3) + text)
}
console.log(`\npack-format arguments:\n`)
log('<version>', ['Retrieve the pack format of any Minecraft version.', ' Defaults to resource pack format when applicable.'])
console.log(`\n${indent(1)}pack-format arguments:`)
log('<version>', ['Retrieve the pack format of any Minecraft version.', indent(1) + 'Defaults to resource pack format when applicable.'])
log('(--data|-d) <version>', ['Retrieve the data pack format in particular when applicable.'])
log('(--resource|-r) <version>', ['Retrieve the resource pack format in particular when applicable.'])
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pack-format",
"version": "1.1.0",
"version": "1.1.1",
"description": "Returns the pack_format of any Minecraft version, including snapshots",
"scripts": {
"test": "node test"
Expand Down
19 changes: 13 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ pack-format is a Node.js tool for retrieving the `pack_format` of any Minecraft

## About

`pack_format` is a version number used in both resource packs and data packs for labeling compatible versions.
`pack_format` is a version number used by Minecraft in both resource packs and data packs for labeling compatible versions.
It was added in Minecraft version 1.6, and as such using this tool on any version prior to that will just return `undefined`.

## Install

Using npm, open your command prompt and type `npm install pack-format` to use for a Node.js project or `npm install -g pack-format` to use from the command line.
pack-format is available on [npm](https://www.npmjs.com/package/pack-format).

To install pack-format, open your command prompt and type `npm install pack-format` to use for a Node.js project, or `npm install -g pack-format` to use from the command line.

## Usage

Expand All @@ -22,16 +24,21 @@ Using npm, open your command prompt and type `npm install pack-format` to use fo
```js
const packFormat = require('pack-format')
packFormat('1.14.4') // 4
packFormat('1.16.2-pre1') // 5
packFormat('1.16.2-pre1', 'resource') // 5
packFormat('20w45a', 'data') // 6
```

### Command line

`pack-format <version>`
`pack-format [--data|--resource] <version>`

```sh
> pack-format 1.14.4
Pack format of 1.14.4 is 4
> pack-format 1.16.2-pre1
Pack format of 1.16.2-pre1 is 5

> pack-format --resource 1.16.2-pre1
Resource pack format of 1.16.2-pre1 is 5

> pack-format --data 20w30a
Data pack format of 20w45a is 6
```

0 comments on commit 25c4e21

Please sign in to comment.