Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Commit

Permalink
fix: hide desc by default
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinNitroG committed Dec 11, 2024
1 parent 354f1fc commit c305e1e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
19 changes: 9 additions & 10 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Check battery health for Windows
> [!IMPORTANT]
> Require [NodeJS](https://nodejs.org/en/download/)
```bash
```sh
# Install via npm
npm i -g win-check-bat
win-check-bat
Expand All @@ -64,12 +64,10 @@ $ win-check-bat
├─────────────────┼───────────────────────┼────────┼───────────┤
│ 54,000 mWh │ 49,680 mWh │ 92% │ Excellent │
└─────────────────┴───────────────────────┴────────┴───────────┘
The battery is in optimal condition, exhibiting minimal degradation and maintaining near-peak performance. It retains most of its original capacity.
```

```
$ win-check-bat -l
$ win-check-bat --line --description
Design capacity: 54,000 mWh
Full charged capacity: 49,680 mWh
Expand All @@ -86,22 +84,23 @@ Usage: win-check-bat [options]
check battery health for Windows
Options:
--no-status don't print out the status and description
--no-status don't print out the status
-d, --description show silly description
-l, --line print line by line
-p, --precise-health calculate precise health (not round)
-o, --open-html open HTML exported file
-T, --open-html-timeout <second> open HTML timeout (s) before deleting temp
file. Increase if your browser cannot open
soon enough before open HTML file.
(default: "1")
-t, --open-html-timeout <second> open HTML timeout (s) before deleting
temp file. Increase if your browser
cannot open soon enough before open
HTML file. (default: "1")
-h, --help display help for command
```

---

## DEV

```bash
```sh
npm i
npm run dev -- -- -- -t -p -o
```
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function init(): Promise<void> {
} catch (e) {
console.error(`Fail to process info: ${e}`);
}
if (options.openHtml) {
if (options.openHtml as boolean | string) {
await open(tempFile);
await sleep(options.openHtmlTimeout * 1000);
}
Expand Down
5 changes: 3 additions & 2 deletions src/modules/commander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import { OptionValues, program } from 'commander';
program
.name('win-check-bat')
.description('check battery health for Windows')
.option('--no-status', "don't print out the status and description")
.option('--no-status', "don't print out the status")
.option('-d, --description', 'show silly description')
.option('-l, --line', 'print line by line')
.option('-p, --precise-health', 'calculate precise health (not round)')
.option('-o, --open-html', 'open HTML exported file')
.option(
'-T, --open-html-timeout <second>',
'-t, --open-html-timeout <second>',
'open HTML timeout (s) before deleting temp file. Increase if your browser cannot open soon enough before open HTML file.',
'1',
);
Expand Down
12 changes: 7 additions & 5 deletions src/modules/processInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ProcessInfo {
const fullChargedNum: number =
ProcessInfo.#extractCapacityNumber(fullCharged);
let health: number = (fullChargedNum / designNum) * 100;
if (options.preciseHealth) {
if (options.preciseHealth as boolean | string) {
health = Math.round(health);
}
const status: Status = getStatus(health);
Expand All @@ -57,8 +57,10 @@ class ProcessInfo {
console.log(`Design capacity: ${this.#info.design}`);
console.log(`Full charged capacity: ${this.#info.fullCharged}`);
console.log(`Battery health: ${this.#info.health}%`);
if (options.status) {
if (options.status as boolean | string) {
console.log(`Status: ${this.#info.status}`);
}
if (options.description as boolean | string) {
console.log(`Description: ${getStatusDesc(this.#info.status)}`);
}
}
Expand All @@ -80,7 +82,7 @@ class ProcessInfo {
color: getStatusColor(this.#info.status),
},
],
disabledColumns: [!options.status ? 'status' : ''],
disabledColumns: [(!options.status as boolean | string) ? 'status' : ''],
});
table.addRow({
design: this.#info.design,
Expand All @@ -90,13 +92,13 @@ class ProcessInfo {
});
table.printTable();
console.log();
if (options.status) {
if (options.description as boolean | string) {
console.log(getStatusDesc(this.#info.status));
}
}

printInfo(): void {
if (options.line) {
if (options.line as boolean | string) {
this.#printInfoLineByLine();
} else {
this.#printInfoTable();
Expand Down

0 comments on commit c305e1e

Please sign in to comment.