Skip to content

Commit

Permalink
Add version command (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
karniv00l authored Oct 18, 2022
1 parent 781dd75 commit d80fbc7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
22 changes: 16 additions & 6 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import { INI } from './ini';
import fs from 'fs';
import { version } from '.';

enum Commands {
VERSION = 'version',
VALIDATE = 'validate',
}

Expand All @@ -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));

Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './ini';
export const version = '0.5.1';

0 comments on commit d80fbc7

Please sign in to comment.