mirror of https://github.com/hyper-tuner/ini.git
Add `version` command (#129)
This commit is contained in:
parent
781dd7579d
commit
d80fbc7571
|
@ -28,10 +28,14 @@ npm i --save @hyper-tuner/ini
|
|||
|
||||
You can also run this package as a CLI tool.
|
||||
|
||||
First you need to provide PAT as a ENV:
|
||||
First you need to authenticate to GitHub Packages:
|
||||
|
||||
```bash
|
||||
export NPM_GITHUB_TOKEN=my_github_personal_access_token
|
||||
npm login --scope=@hyper-tuner --registry=https://npm.pkg.github.com
|
||||
|
||||
> Username: USERNAME
|
||||
> Password: TOKEN
|
||||
> Email: PUBLIC-EMAIL-ADDRESS
|
||||
```
|
||||
|
||||
No you can run the tool:
|
||||
|
|
22
src/cli.ts
22
src/cli.ts
|
@ -2,8 +2,10 @@
|
|||
|
||||
import { INI } from './ini';
|
||||
import fs from 'fs';
|
||||
import { version } from '.';
|
||||
|
||||
enum Commands {
|
||||
VERSION = 'version',
|
||||
VALIDATE = 'validate',
|
||||
}
|
||||
|
||||
|
@ -18,6 +20,10 @@ const showUsage = () => {
|
|||
process.exit(1);
|
||||
};
|
||||
|
||||
const showVersion = () => {
|
||||
console.info(`\nℹ Version: ${version}`);
|
||||
};
|
||||
|
||||
const validate = (filename: string) => {
|
||||
const ini = new INI(loadFile(filename));
|
||||
|
||||
|
@ -41,17 +47,21 @@ if (!command) {
|
|||
process.exit(1);
|
||||
}
|
||||
|
||||
if (!filename) {
|
||||
console.info('❗️ Please provide a file name');
|
||||
showUsage();
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
switch (command) {
|
||||
case Commands.VALIDATE:
|
||||
if (!filename) {
|
||||
console.info('❗️ Please provide a file name');
|
||||
showUsage();
|
||||
process.exit(1);
|
||||
}
|
||||
showVersion();
|
||||
validate(filename);
|
||||
break;
|
||||
|
||||
case Commands.VERSION:
|
||||
showVersion();
|
||||
break;
|
||||
|
||||
default:
|
||||
console.info(`❗️ Unknown command: ${command}, please use one of: [${Object.values(Commands).join(', ')}]`);
|
||||
process.exit(1);
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
export * from './ini';
|
||||
export const version = '0.5.1';
|
||||
|
|
Loading…
Reference in New Issue