Skip to content

Commit

Permalink
feat: Add a flag to hide ASCII art (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
golota60 committed Apr 10, 2021
1 parent 2586899 commit cfb18dd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ Yayfetch is a tool similar to screenfetch - except you can use it on a non-linux

```npx yayfetch``` - returns info about your system

```npx yayfetch -p``` or ```npx yayfetch --pick``` - first asks you what information you want to display, then displays it
### Flags

```npx yayfetch -c``` or ```npx yayfetch --color``` - allows to specify in which color the data will be shown in predefined colors. Cannot be used with --rgb flag. Available predefined colors:
```-p``` or ```--pick``` - first asks you what information you want to display, then displays it

```-c <color>``` or ```--color <color>``` - allows to specify in which color the data will be shown in predefined colors. Cannot be used with --rgb flag. Available predefined colors:
`pink`(default), `orange`, `green`, `white`, `black`, `red`, `blue`, `yellow`

```npx yayfetch --rgb r,g,b``` - specify RGB values in which data will be shown. Cannot be used with -c(--color) flag. Example ```npx yayfetch --rgb 125,25,78```
```--rgb r,g,b``` - specify RGB values in which data will be shown. Cannot be used with -c(--color) flag. Example ```npx yayfetch --rgb 125,25,78```

``` --hide-logo ``` - prints data without ASCII art

```npx yayfetch -h``` or ```npx yayfetch --help``` - shows available flags.
```-h``` or ```--help``` - shows available flags.

More features to come!

Expand Down
8 changes: 8 additions & 0 deletions src/helpers/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ export const printInTwoColumns = (col1: string, col2: string): void => {
);
};

export const printData = ({ logo, data }: { logo: string; data: string }, hideLogo: boolean = false): void => {
if (hideLogo) {
console.log(data);
} else {
printInTwoColumns(logo, data);
}
};

export const yayfetchASCII = `
████ ████████ ████
███████ ██████████ ███████
Expand Down
16 changes: 13 additions & 3 deletions src/yayfetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
printInTwoColumns,
returnColoredText,
parseRGBStringToNumber,
printData,
} from './helpers/helpers';
import {
getEndianness,
Expand Down Expand Up @@ -117,13 +118,17 @@ const args = yargs
const predefinedColor = String(yargs.argv.c || yargs.argv.color);
const customColors = yargs.argv.rgb ? parseRGBStringToNumber(String(yargs.argv.rgb)) : false;
const colorToUse = customColors || predefinedColor;
const hideLogoFlag = Boolean(yargs.argv['hide-logo']);

let infoToPrint;
if (yargs.argv.p || yargs.argv.pick) {
const inquirerPrompt = await inquirer.prompt<{ displayedValues: Array<string> }>([promptQuestions]);
const pickedData = await returnPickedData(inquirerPrompt.displayedValues, colorToUse);
printInTwoColumns(returnColoredText(yayfetchASCII, colorToUse), pickedData);
infoToPrint = await returnPickedData(inquirerPrompt.displayedValues, colorToUse);
} else {
printInTwoColumns(returnColoredText(yayfetchASCII, colorToUse), await allData(colorToUse));
infoToPrint = await allData(colorToUse);
}

printData({ logo: returnColoredText(yayfetchASCII, colorToUse), data: infoToPrint }, hideLogoFlag);
} catch (err) {
console.error(`‼️ ${err} ‼️`);
}
Expand All @@ -142,6 +147,11 @@ const args = yargs
choices: ['pink', 'orange', 'green', 'white', 'black', 'red', 'blue', 'yellow'],
type: 'string',
})
.option('hide-logo', {
describe: 'Hides the ASCII logo',
type: 'boolean',
default: false,
})
.option('rgb', {
describe: 'Same as color, but you provide r,g,b values ex. 128,5,67',
type: 'string',
Expand Down

0 comments on commit cfb18dd

Please sign in to comment.