Skip to content

Commit

Permalink
general refactoring for readability, update screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
ExperiBass committed Aug 31, 2023
1 parent 51ae23e commit 1f9f5a7
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 38 deletions.
10 changes: 5 additions & 5 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ There's also a package in the AUR, maintained by `u/rhysperry111`! Install it wi

# Usage

`cli-pride-flags [options...] flag`
```
cli-pride-flags [options...] flag
Options:
--blend, -b flag[,factor] Blend two flags together, with an optional decimal factor
--character, -c char Character to use to draw the flag
--gradient, -g Make the flag a smooth gradient
--help, -h Display this help text
--live, -l Hold the terminal and redraw the flag upon resize, closing when any key is pressed
--vertical, -v Display the flag, but vertically

- Flag is the name of the flag-- for example, you could input `bi`, `trans`, `transfem`, etc.
```
Example: `cli-pride-flags -l trans` would display the trans flag and hold the terminal.

# Screenshots
Expand All @@ -34,11 +34,11 @@ Some screenshots are below!

![agen, bi, fluid](./screenies/1.png)

![some more flags](./screenies/2.png)
![bunch of flags and help menu :D](./screenies/2.png)

# Issues

none :D
none, hopefully uwu

# TODO
- commit more crimes, but queerly
55 changes: 28 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
{
"name": "cli-pride-flags",
"version": "1.4.0",
"description": "Displays pride flags in your terminal~",
"main": "src/main.js",
"bin": {
"cli-pride-flags": "src/main.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ExperiBass/cli-pride-flags.git"
},
"keywords": [
"pride",
"pride-flags",
"cli"
],
"author": "ExperiBass",
"license": "GPL-3.0-or-later",
"bugs": {
"url": "https://github.com/ExperiBass/cli-pride-flags/issues"
},
"homepage": "https://github.com/ExperiBass/cli-pride-flags#readme",
"dependencies": {
"chalk": "^4.1.2",
"cli-columns": "^4.0.0"
}
}
"name": "cli-pride-flags",
"version": "1.4.0",
"description": "Displays pride flags in your terminal~",
"main": "src/main.js",
"bin": {
"cli-pride-flags": "src/main.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ExperiBass/cli-pride-flags.git"
},
"keywords": [
"pride",
"pride-flags",
"cli",
"terminal"
],
"author": "ExperiBass",
"license": "GPL-3.0-or-later",
"bugs": {
"url": "https://github.com/ExperiBass/cli-pride-flags/issues"
},
"homepage": "https://github.com/ExperiBass/cli-pride-flags#readme",
"dependencies": {
"chalk": "^4.1.2",
"cli-columns": "^4.0.0"
}
}
Binary file modified screenies/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenies/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const argparser = new ArgParser({
'live': { type: 'boolean', short: 'l', description: 'Hold the terminal and redraw the flag upon resize, closing when any key is pressed' },
'vertical': { type: 'boolean', short: 'v', description: 'Display the flag, but vertically' },
'blend': { type: 'string', short: 'b', description: 'Blend two flags together, with an optional decimal factor', argName: 'flag[,factor]' },
'character': {type: 'string', short: 'c', description: 'Character to use to draw the flag', argName: 'char'}
'character': { type: 'string', short: 'c', description: 'Character to use to draw the flag', argName: 'char' }
})

// setup
const { args, options } = argparser.parse()
const BLOCK = options.character?.substring(0, 1) || "█"
const CHAR = options.character?.trim().substring(0, 1) || "█"
const CHOSEN_FLAG = args[0]
const availableHeight = process.stdout.rows
const availableWidth = process.stdout.columns
Expand All @@ -35,7 +35,7 @@ function help() {
let flagLine = `${flagName}` // indent the line...
flagLine = flagLine.padEnd(flagLine.length + spaces, " ") // ...add calculated spaces...
for (const color of flags[flagName].stripes) {
flagLine += chalk.hex(color.code)(BLOCK) // ..and then add the miniflag
flagLine += chalk.hex(color.code)(CHAR) // ..and then add the miniflag
}
flagList.push(flagLine)
}
Expand Down Expand Up @@ -78,7 +78,7 @@ function createFlag(availableWidth, availableHeight, options) {
const color2 = blendColors.getColor(position, options.gradient ? 'gradient' : null)
color = interpolateColor(color, color2, blendFactor)
}
finishedFlag += chalk.hex(color)(BLOCK)
finishedFlag += chalk.hex(color)(CHAR)
}
return finishedFlag.repeat(availableHeight)
}
Expand All @@ -94,7 +94,7 @@ function createFlag(availableWidth, availableHeight, options) {
const color2 = blendColors.getColor(position, options.gradient ? 'gradient' : null)
color = interpolateColor(color, color2, blendFactor)
}
finishedFlag += chalk.hex(color)(BLOCK.repeat(availableWidth))
finishedFlag += chalk.hex(color)(CHAR.repeat(availableWidth))
currLine++
}
return finishedFlag
Expand Down
2 changes: 1 addition & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class ArgParser {
try {
const { values, positionals } = parseArgs({ args: inputArray, options: this.#options, allowPositionals: true })
return { args: positionals, options: values }
} catch(e) {
} catch (e) {
console.log(e.message)
process.exit(1)
}
Expand Down

0 comments on commit 1f9f5a7

Please sign in to comment.