Skip to content

Commit e0bcccc

Browse files
committed
ascii-cli-10: add points
1 parent c0dde2b commit e0bcccc

File tree

4 files changed

+95
-60
lines changed

4 files changed

+95
-60
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"devDependencies": {
2121
"@types/jest": "^29.5.14",
2222
"@types/node": "^22.15.17",
23-
"@typescript-eslint/eslint-plugin": "^8.32.0",
24-
"@typescript-eslint/parser": "^8.32.0",
23+
"@typescript-eslint/eslint-plugin": "^8.32.1",
24+
"@typescript-eslint/parser": "^8.32.1",
2525
"eslint": "^9.26.0",
2626
"eslint-config-prettier": "^10.1.5",
2727
"eslint-plugin-import": "^2.31.0",
@@ -52,7 +52,7 @@
5252
"dist/**/*"
5353
],
5454
"dependencies": {
55-
"simple-ascii-chart": "^5.0.0",
55+
"simple-ascii-chart": "^5.1.0",
5656
"yargs": "^17.7.2"
5757
}
5858
}

src/cli.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
validateLegend,
1414
validateThresholds,
1515
validateYRange,
16+
validatePoints,
1617
} from './validators';
1718

1819
// Define command-line arguments with yargs
@@ -90,7 +91,11 @@ const { argv } = yargs
9091
})
9192
.option('thresholds', {
9293
type: 'array',
93-
description: 'Array of threshold points or lines with optional color',
94+
description: 'Array of threshold lines with optional color',
95+
})
96+
.option('points', {
97+
type: 'array',
98+
description: 'Array of points with optional color',
9499
})
95100
.option('legend', {
96101
type: 'string',
@@ -147,6 +152,7 @@ const prepareParams = ({
147152
yRange,
148153
showTickLabel,
149154
thresholds,
155+
points,
150156
legend,
151157
formatter,
152158
lineFormatter,
@@ -169,6 +175,7 @@ const prepareParams = ({
169175
yRange?: (string | number)[];
170176
showTickLabel?: boolean;
171177
thresholds?: (string | number)[];
178+
points?: (string | number)[];
172179
legend?: string;
173180
formatter?: string;
174181
lineFormatter?: string;
@@ -197,6 +204,7 @@ const prepareParams = ({
197204
yRange: validateYRange(yRange), // Validate and format yRange
198205
showTickLabel,
199206
thresholds: validateThresholds(thresholds), // Validate and format thresholds
207+
points: validatePoints(points), // Validate and format thresholds
200208
legend: validateLegend(legend), // Validate and format legend
201209
formatter: validateFormatter(formatter), // Parse formatter as a function
202210
lineFormatter: validateLineFormatter(lineFormatter), // Parse lineFormatter as a function

src/validators.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
Colors,
44
CustomSymbol,
55
Formatter,
6+
GraphPoint,
67
Legend,
78
LineFormatterArgs,
89
MaybePoint,
@@ -81,6 +82,27 @@ export const validateThresholds = (
8182
.filter((threshold): threshold is Threshold => threshold !== undefined);
8283
};
8384

85+
// Helper function to validate and format thresholds as Threshold[]
86+
export const validatePoints = (
87+
points: any[] | undefined, // Updated type to any[] | undefined
88+
): GraphPoint[] | undefined => {
89+
if (!Array.isArray(points)) return undefined;
90+
91+
return points
92+
.map((item) => {
93+
if (typeof item === 'object' && item !== null) {
94+
const point = item as any;
95+
const x = point.x;
96+
const y = point.y;
97+
const color = typeof point.color === 'string' ? point.color : undefined;
98+
99+
return x !== undefined && y !== undefined ? ({ x, y, color } as GraphPoint) : undefined;
100+
}
101+
return undefined;
102+
})
103+
.filter((point): point is GraphPoint => point !== undefined);
104+
};
105+
84106
// Helper function to validate and parse legend as Legend
85107
export const validateLegend = (legend: string | undefined): Legend | undefined => {
86108
if (!legend) return undefined;

yarn.lock

Lines changed: 61 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -793,85 +793,85 @@
793793
dependencies:
794794
"@types/yargs-parser" "*"
795795

796-
"@typescript-eslint/eslint-plugin@^8.32.0":
797-
version "8.32.0"
798-
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.32.0.tgz#86630dd3084f9d6c4239bbcd6a7ee1a7ee844f7f"
799-
integrity sha512-/jU9ettcntkBFmWUzzGgsClEi2ZFiikMX5eEQsmxIAWMOn4H3D4rvHssstmAHGVvrYnaMqdWWWg0b5M6IN/MTQ==
796+
"@typescript-eslint/eslint-plugin@^8.32.1":
797+
version "8.32.1"
798+
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.32.1.tgz#9185b3eaa3b083d8318910e12d56c68b3c4f45b4"
799+
integrity sha512-6u6Plg9nP/J1GRpe/vcjjabo6Uc5YQPAMxsgQyGC/I0RuukiG1wIe3+Vtg3IrSCVJDmqK3j8adrtzXSENRtFgg==
800800
dependencies:
801801
"@eslint-community/regexpp" "^4.10.0"
802-
"@typescript-eslint/scope-manager" "8.32.0"
803-
"@typescript-eslint/type-utils" "8.32.0"
804-
"@typescript-eslint/utils" "8.32.0"
805-
"@typescript-eslint/visitor-keys" "8.32.0"
802+
"@typescript-eslint/scope-manager" "8.32.1"
803+
"@typescript-eslint/type-utils" "8.32.1"
804+
"@typescript-eslint/utils" "8.32.1"
805+
"@typescript-eslint/visitor-keys" "8.32.1"
806806
graphemer "^1.4.0"
807-
ignore "^5.3.1"
807+
ignore "^7.0.0"
808808
natural-compare "^1.4.0"
809809
ts-api-utils "^2.1.0"
810810

811-
"@typescript-eslint/parser@^8.32.0":
812-
version "8.32.0"
813-
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-8.32.0.tgz#fe840ecb2726a82fa9f5562837ec40503ae71caf"
814-
integrity sha512-B2MdzyWxCE2+SqiZHAjPphft+/2x2FlO9YBx7eKE1BCb+rqBlQdhtAEhzIEdozHd55DXPmxBdpMygFJjfjjA9A==
811+
"@typescript-eslint/parser@^8.32.1":
812+
version "8.32.1"
813+
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-8.32.1.tgz#18b0e53315e0bc22b2619d398ae49a968370935e"
814+
integrity sha512-LKMrmwCPoLhM45Z00O1ulb6jwyVr2kr3XJp+G+tSEZcbauNnScewcQwtJqXDhXeYPDEjZ8C1SjXm015CirEmGg==
815815
dependencies:
816-
"@typescript-eslint/scope-manager" "8.32.0"
817-
"@typescript-eslint/types" "8.32.0"
818-
"@typescript-eslint/typescript-estree" "8.32.0"
819-
"@typescript-eslint/visitor-keys" "8.32.0"
816+
"@typescript-eslint/scope-manager" "8.32.1"
817+
"@typescript-eslint/types" "8.32.1"
818+
"@typescript-eslint/typescript-estree" "8.32.1"
819+
"@typescript-eslint/visitor-keys" "8.32.1"
820820
debug "^4.3.4"
821821

822-
"@typescript-eslint/[email protected].0":
823-
version "8.32.0"
824-
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-8.32.0.tgz#6be89f652780f0d3d19d58dc0ee107b1a9e3282c"
825-
integrity sha512-jc/4IxGNedXkmG4mx4nJTILb6TMjL66D41vyeaPWvDUmeYQzF3lKtN15WsAeTr65ce4mPxwopPSo1yUUAWw0hQ==
822+
"@typescript-eslint/[email protected].1":
823+
version "8.32.1"
824+
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-8.32.1.tgz#9a6bf5fb2c5380e14fe9d38ccac6e4bbe17e8afc"
825+
integrity sha512-7IsIaIDeZn7kffk7qXC3o6Z4UblZJKV3UBpkvRNpr5NSyLji7tvTcvmnMNYuYLyh26mN8W723xpo3i4MlD33vA==
826826
dependencies:
827-
"@typescript-eslint/types" "8.32.0"
828-
"@typescript-eslint/visitor-keys" "8.32.0"
827+
"@typescript-eslint/types" "8.32.1"
828+
"@typescript-eslint/visitor-keys" "8.32.1"
829829

830-
"@typescript-eslint/[email protected].0":
831-
version "8.32.0"
832-
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-8.32.0.tgz#5e0882393e801963f749bea38888e716045fe895"
833-
integrity sha512-t2vouuYQKEKSLtJaa5bB4jHeha2HJczQ6E5IXPDPgIty9EqcJxpr1QHQ86YyIPwDwxvUmLfP2YADQ5ZY4qddZg==
830+
"@typescript-eslint/[email protected].1":
831+
version "8.32.1"
832+
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-8.32.1.tgz#b9292a45f69ecdb7db74d1696e57d1a89514d21e"
833+
integrity sha512-mv9YpQGA8iIsl5KyUPi+FGLm7+bA4fgXaeRcFKRDRwDMu4iwrSHeDPipwueNXhdIIZltwCJv+NkxftECbIZWfA==
834834
dependencies:
835-
"@typescript-eslint/typescript-estree" "8.32.0"
836-
"@typescript-eslint/utils" "8.32.0"
835+
"@typescript-eslint/typescript-estree" "8.32.1"
836+
"@typescript-eslint/utils" "8.32.1"
837837
debug "^4.3.4"
838838
ts-api-utils "^2.1.0"
839839

840-
"@typescript-eslint/[email protected].0":
841-
version "8.32.0"
842-
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-8.32.0.tgz#a4a66b8876b8391970cf069b49572e43f1fc957a"
843-
integrity sha512-O5Id6tGadAZEMThM6L9HmVf5hQUXNSxLVKeGJYWNhhVseps/0LddMkp7//VDkzwJ69lPL0UmZdcZwggj9akJaA==
840+
"@typescript-eslint/[email protected].1":
841+
version "8.32.1"
842+
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-8.32.1.tgz#b19fe4ac0dc08317bae0ce9ec1168123576c1d4b"
843+
integrity sha512-YmybwXUJcgGqgAp6bEsgpPXEg6dcCyPyCSr0CAAueacR/CCBi25G3V8gGQ2kRzQRBNol7VQknxMs9HvVa9Rvfg==
844844

845-
"@typescript-eslint/[email protected].0":
846-
version "8.32.0"
847-
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-8.32.0.tgz#11d45f47bfabb141206a3da6c7b91a9d869ff32d"
848-
integrity sha512-pU9VD7anSCOIoBFnhTGfOzlVFQIA1XXiQpH/CezqOBaDppRwTglJzCC6fUQGpfwey4T183NKhF1/mfatYmjRqQ==
845+
"@typescript-eslint/[email protected].1":
846+
version "8.32.1"
847+
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-8.32.1.tgz#9023720ca4ecf4f59c275a05b5fed69b1276face"
848+
integrity sha512-Y3AP9EIfYwBb4kWGb+simvPaqQoT5oJuzzj9m0i6FCY6SPvlomY2Ei4UEMm7+FXtlNJbor80ximyslzaQF6xhg==
849849
dependencies:
850-
"@typescript-eslint/types" "8.32.0"
851-
"@typescript-eslint/visitor-keys" "8.32.0"
850+
"@typescript-eslint/types" "8.32.1"
851+
"@typescript-eslint/visitor-keys" "8.32.1"
852852
debug "^4.3.4"
853853
fast-glob "^3.3.2"
854854
is-glob "^4.0.3"
855855
minimatch "^9.0.4"
856856
semver "^7.6.0"
857857
ts-api-utils "^2.1.0"
858858

859-
"@typescript-eslint/[email protected].0":
860-
version "8.32.0"
861-
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-8.32.0.tgz#24570f68cf845d198b73a7f94ca88d8c2505ba47"
862-
integrity sha512-8S9hXau6nQ/sYVtC3D6ISIDoJzS1NsCK+gluVhLN2YkBPX+/1wkwyUiDKnxRh15579WoOIyVWnoyIf3yGI9REw==
859+
"@typescript-eslint/[email protected].1":
860+
version "8.32.1"
861+
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-8.32.1.tgz#4d6d5d29b9e519e9a85e9a74e9f7bdb58abe9704"
862+
integrity sha512-DsSFNIgLSrc89gpq1LJB7Hm1YpuhK086DRDJSNrewcGvYloWW1vZLHBTIvarKZDcAORIy/uWNx8Gad+4oMpkSA==
863863
dependencies:
864864
"@eslint-community/eslint-utils" "^4.7.0"
865-
"@typescript-eslint/scope-manager" "8.32.0"
866-
"@typescript-eslint/types" "8.32.0"
867-
"@typescript-eslint/typescript-estree" "8.32.0"
865+
"@typescript-eslint/scope-manager" "8.32.1"
866+
"@typescript-eslint/types" "8.32.1"
867+
"@typescript-eslint/typescript-estree" "8.32.1"
868868

869-
"@typescript-eslint/[email protected].0":
870-
version "8.32.0"
871-
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-8.32.0.tgz#0cca2cac046bc71cc40ce8214bac2850d6ecf4a6"
872-
integrity sha512-1rYQTCLFFzOI5Nl0c8LUpJT8HxpwVRn9E4CkMsYfuN6ctmQqExjSTzzSk0Tz2apmXy7WU6/6fyaZVVA/thPN+w==
869+
"@typescript-eslint/[email protected].1":
870+
version "8.32.1"
871+
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-8.32.1.tgz#4321395cc55c2eb46036cbbb03e101994d11ddca"
872+
integrity sha512-ar0tjQfObzhSaW3C3QNmTc5ofj0hDoNQ5XWrCy6zDyabdr0TWhCkClp+rywGNj/odAFBVzzJrK4tEq5M4Hmu4w==
873873
dependencies:
874-
"@typescript-eslint/types" "8.32.0"
874+
"@typescript-eslint/types" "8.32.1"
875875
eslint-visitor-keys "^4.2.0"
876876

877877
accepts@^2.0.0:
@@ -2240,11 +2240,16 @@ [email protected], iconv-lite@^0.6.3:
22402240
dependencies:
22412241
safer-buffer ">= 2.1.2 < 3.0.0"
22422242

2243-
ignore@^5.2.0, ignore@^5.3.1:
2243+
ignore@^5.2.0:
22442244
version "5.3.2"
22452245
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.2.tgz#3cd40e729f3643fd87cb04e50bf0eb722bc596f5"
22462246
integrity sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==
22472247

2248+
ignore@^7.0.0:
2249+
version "7.0.4"
2250+
resolved "https://registry.yarnpkg.com/ignore/-/ignore-7.0.4.tgz#a12c70d0f2607c5bf508fb65a40c75f037d7a078"
2251+
integrity sha512-gJzzk+PQNznz8ysRrC0aOkBNVRBDtE1n53IqyqEf3PXrYwomFs5q4pGMizBMJF+ykh03insJ27hB8gSrD2Hn8A==
2252+
22482253
import-fresh@^3.2.1:
22492254
version "3.3.0"
22502255
resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b"
@@ -3658,10 +3663,10 @@ signal-exit@^3.0.3, signal-exit@^3.0.7:
36583663
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9"
36593664
integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==
36603665

3661-
simple-ascii-chart@^5.0.0:
3662-
version "5.0.0"
3663-
resolved "https://registry.yarnpkg.com/simple-ascii-chart/-/simple-ascii-chart-5.0.0.tgz#4186762abe608db9385774f0885717075a084851"
3664-
integrity sha512-AirrqLPiPB5tGRgiyZoriQuJzlAFZx82AdkknOEQSlq6EIaJ5FIm9uaY93b6lrpVxWXlWjDAIQgRShfgJSXgkw==
3666+
simple-ascii-chart@^5.1.0:
3667+
version "5.1.0"
3668+
resolved "https://registry.yarnpkg.com/simple-ascii-chart/-/simple-ascii-chart-5.1.0.tgz#496a2b7a8a2f146a7a3e9309e86602a8c91b9609"
3669+
integrity sha512-4es8skTegTdnA6px2s97Zkv0k/Ra3+oaEHHx27wnt+HhDUu83Hl7YfiRZUTxE3XF+ClWgnpO6FYsw8QejKX5SQ==
36653670

36663671
sisteransi@^1.0.5:
36673672
version "1.0.5"

0 commit comments

Comments
 (0)